Input
1. n
2. n elements
Output
1. l
2. s
Method:
1 start
2. read n
3. for(i=0;i<n;i++)
read Ai
4. write n
5. for(i=0;i<n;i++)
write Ai
6. lar_smal(n, A);
7.stop
//before the main program
void lar_small(int n, int A[])
begin
int l=A[0], s=A[0];
for(i=1;i<n;i++)
begin
if(l<A[i])
begin
l=A[i];
end
end
write"larger=",l;
for(i=1;i<n;i++)
begin
if(s>A[i])
begin
s=A[i];
end
end
write"smaller=",s;
end.
No comments:
Post a Comment