GIANT ELEMENT
Problem Description
Karishma, a little girl who is always playing with her friend Sushmi. Sushmi and Karishma has a task today that they have to find the largest number from the given set. Will you help them?
CODING ARENA::
#include <stdio.h>
int main()
{
int a[100],i,j,n,t;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("%d",a[i-1]);
return 0;
}
Test Case 1
Input (stdin)3
1 3 2
Expected Output
3
Test Case 2
Input (stdin)5
8 7 6 9 4
Expected Output
9
No comments:
Post a Comment