Problem E: 最大的数
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 915 Solved: 240
[Submit][Status]
Description
给出一组序列,求出这组序列中的最大的值
Input
每组测试样例第一行为一个整数n,后面跟有n个非负整数组成的序列。当n为0时输入结束
Output
找出这组序列中最大的值并输出,每组样例占一行
Sample Input
20
0 56 19 80 58 47 35 89 82 74 17 85 71 51 30 1 9 36 14 16
10
3 85 31 121 88 73 54 134 123 112
0
Sample Output
89
134
HINT
不需要用数组
Append Code
#include <stdio.h>
int main()
{ //
int a,i,g,m=0;
while(scanf("%d",&a)!=EOF)//我最开始写的是1,1不行,但只要改成这种形式就可以了,毕竟我们中断是靠的break。懂不?
{ m=0;
for(i=1; i<=a; i++)
{
scanf("%d",&g);
if(g>m)m=g;
}
if(a==0)
{
break;
}
printf("%d\n",m);
}
return 0;
}
给俺点个赞!