题解 | #小乐乐找最大数#
小乐乐找最大数
http://www.nowcoder.com/practice/ae6a21920cac4f9184c8ecfcc87f89b9
#include <stdio.h>
int main()
{
int n1, n2, n3, n4;
//用数组来保存四个科目的成绩
scanf("%d %d %d %d", &n1, &n2, &n3, &n4);
int score[4] = {n1,n2,n3,n4};
//假定第一个元素为最大值
int max = score[0];
int i = 0;
for(i = 1; i < 4; i ++)
{
//逐个比较
if(score[i] > max)
{
max = score[i];
}
}
printf("%d\n", max);
return 0;
}