You are on page 1of 2

liststundents.

txt

while (not eof()) {

arrays

Begin

read a[0], a[1], ...,a[99];

max = a[0];

For (i=1;i<=99;i++)

If (a[i]>max) then max = a[i];


End If

End For;

Print max;

End;

write pseudocode to find the maximum and the minimum.


exchange positions

Begin

read a[0], a[1], ...,a[99];

max = a[0];
min = a[0];

maxpos =0;
minpos=0;

For (i=1;i<=99;i++)

If (a[i]>max)
then max = a[i];
maxpos = i;
End If

If (a[i]<min)
then min = a[i];
minpos = i;
End If

End For;

a[minpos] = max;
a[maxpos] = min;

Print maxpos;
Print minpos;
Print a[maxpos];
Print a[minpos];

End;

You might also like