|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我是用VS2017编译的
#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
struct student {
int num;
char name;
int computer, english, math;
double average;
};
int main(int argc, char* argv[]) {
system("color 0b");
int i, n;
struct student max, s1;
printf("Input n");
scanf_s("%d", &n);
for (i = 1; i <= n; i++) {
printf("No.%d", i);
scanf_s("%d %s %d %d %d", &s1.num, &s1.name, &s1.computer, &s1.english, &s1.math);
s1.average = (s1.math + s1.computer + s1.english) / 3.0;
if (i == 1) {
max = s1;
}
if (max.average < s1.average) {
max = s1;
}
}
printf("num:%d,name:%s,average:%f\n", max.num, max.name, max.average);
system("pause");
}
|
|