Вы находитесь на странице: 1из 2

Declare search,swap,fswap as string

Declare c as boolean
Declare ARRAY SArray[5][6] as string
Declare ARRAY id_num[30] as integer
Declar ARRAY seat[5][6] as integer
Declare i,j,k as integer
frow,fcolumn as integer
i=o
Begin()
SArray()
bsort_desc()
bsort_asc()
print "Would you like to search for a particular student"
read ans
if ans='yes' then begin
find()
else
begin()
endif
End
Function SArray():string
for j=1to5 do begin
for k=1 to 6 do begin
print "Enter the name of the member"
read SArray[i]
print "Please enter the member's id number"
read id_num[j][k]
seat[j][k]<-[j][k]
i=i+1
k=k+1
seat
endfor
j=j+1
endfor
Begin()
End function SArray
Function bsort_desc():string
for i=1 to 30 do begin
for j=1to5 do begin
for k=1 to 6 do begin
if SArray[i]<SArray[i+1] then begin
swap=SArray[i]
SArray[i]=SArray[i+1]
SArray[i+1]=swap
fswap=seat[j][k]
seat[j][k]=seat[j][k+1]
seat[j][k+1]=fswap
endif
k=k+1
endfor
j=j+1
endfor
endfor
Begin()
End function bsort_desc
Function bsort_asc()
for i=1 to 30 do begin
for j=1to5 do begin
for k=1 to 6 do begin

if SArray[i]>SArray[i+1] then begin


swap=SArray[i]
SArray[i]=SArray[i+1]
SArray[i+1]=swap
fswap=seat[j][k]
seat[j][k]=seat[j][k+1]
seat[j][k+1]=fswap
endif
k=k+1
endfor
j=j+1
endfor
endfor
seatc_display()
End function bsort_asc
Function Seatc_display():string
i=0
for j=1to5 do begin
for k=1 to 6 do begin
if i<=30 then begin
print "name: ",SArray[i]
print "column: ",seat[j]
print "row: ",seat[k]
i=i+1
endif
endfor
endfor
Begin()
End function Seatc_display
function find():string
print"Enter the name you wish to search for"
read search
for j=1to5 do begin
for k=1 to 6 do begin
if SArray[i]=search then begin
found=0
fcolumn=j
frow=k
else
found=1
k=k+1
endif
endfor
j=j+1
endfor
If found=0 then begin
print search" is found."
print search" is located at column: ",fcolumn," and row: ",frow"
."
else
print search," is not present in the class."
print "Do yo want to search for another person"
read c
if c='yes' then begin
function find()
else
function seatc_display()
endif
endif
End function find

Вам также может понравиться