输入10个学生的学号和5门课程的成绩,统计输出5门课总分最高和最低的学生的学号和他们的总分。
AC代码:
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
long long max, sum, min,m, M;
long long a[10][6];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 6; j++)
{
cin >> a[i][j];
}
}
for (int i = 0; i < 10; i++)
{
sum = 0;
for (int j = 1; j < 6; j++)
{
sum += a[i][j];
}
if (i==0)
{
max = sum; M = i; m = i; min = sum;
}
else
{
if (sum > max)
{
max = sum; M = i;
}
if (sum < min)
{
min= sum; m = i;
}
}
}
cout << a[M][0] << " " << max << endl;
cout << a[m][0] << " " << min << endl;
return 0;
}