URI Online Judge Solution 1080 Highest and Position using C Programming Language.
Read 100 integer numbers. Print the highest read value and the input position.
Input
The input file contains 100 distinct positive integer numbers.
Output
Print the highest number read and the input position of this value, according to the given example.
Input Sample | Output Sample |
2
113 45 34565 6 ... 8 |
34565
4 |
Solution using C :
#include <stdio.h>
int main() {
int n[100],i,m,p;
for(i=0; i<100; i++)
{
scanf("%d",&n[i]);
if(i==0)
{
m = n[i];
p = i;
}
else
{
if(m<n[i])
{
m = n[i];
p = i;
}
}
}
printf("%d\n%d\n",m,p+1);
return 0;
}
Comments
Post a Comment