看了讨论还是不明白为啥我是90分。
查看原帖
看了讨论还是不明白为啥我是90分。
450482
jisp123楼主2022/8/1 19:18
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;

struct student {
	char name[10];
	int a,b,c,sum;
};

bool cmp(student tmp2,student tmp3) {
	return tmp2.sum > tmp3.sum;

}

student tmp[1100];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp[i].name >> tmp[i].a >> tmp[i].b >> tmp[i].c;
		tmp[i].sum = tmp[i].a + tmp[i].b + tmp[i].c;
	}
	sort(tmp, tmp + n, cmp);
	cout << tmp[0].name <<" "<< tmp[0].a <<" "<< tmp[0].b <<" "<< tmp[0].c;
	
}

这是我程序第一个样例跑出来的结果pzztktv 0 0 0,和样例一给的output一样。不太明白为啥过不了,都是零的话不就是默认输出第一个吗?

2022/8/1 19:18
加载中...