Algorithm StraightMaxMin(a n, max, min)
//Set max to the maximum and min to the minimum of a[1:n].
{
max = min = a[1];
for i:=2 to n do
{
if(max<a[i] then max:=a[i]);
if(min>a[i] then min:=a[i]);
}
}
//Set max to the maximum and min to the minimum of a[1:n].
{
max = min = a[1];
for i:=2 to n do
{
if(max<a[i] then max:=a[i]);
if(min>a[i] then min:=a[i]);
}
}
No comments:
Post a Comment