找出一批学生的最高分 (15分)
本题要求编写程序,找出最高分。
输入格式:
输入在一行中给出一系列非负整数,其间以空格分隔。当读到负整数时,表示输入结束,该数字不要处理。
输出格式:
在一行中输出最高分。
输入样例:
在这里给出一组输入。例如:
67 88 73 54 0 95 60 -1
输出样例:
在这里给出相应的输出。例如:
95
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n,max,i;
scanf("%d",&n);
int a[n];
max=0;
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]>max)
max=a[i];
}
printf("%d",max);
return 0;
}