WHO IS BIG AND WHO IS DWARF
Problem Description
Rakshan had a bowl of corns. He is eating the huge corn followed by little corn. For that he has to find large and small corns to eat. Consider numbers instead of corns. Can you find the largest and smallest one?
CODING ARENA
#include <stdio.h>
int main()
{
int a[50],i,n,l,s;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
l=s=a[0];
for(i=1;i<n;++i)
{
if(a[i]>l)
l=a[i];
if(a[i]<s)
s=a[i];
}
printf("%d",l);
printf("\n%d",s);
return 0;
}
Test Case 1
Input (stdin)5
1 8 9 7 5
Expected Output
9
1
Test Case 2
Input (stdin)4
9 19 7 8
Expected Output
19
7
Worldwide Tweets is your news, entertainment, music fashion website. We provide you with the latest breaking news and videos straight from the entertainment industry. Visit dwarf tossing for more details.
ReplyDelete