求助,请问哪里有问题
查看原帖
求助,请问哪里有问题
1344077
nnnnnnnn1楼主2024/4/29 14:28
#include<iostream>
#include<cstring>
using namespace std;
struct Student {
	string name;
	int x, y, z;
	int score=x+y+z;
	int id;
};
bool isPrior(Student& a, Student& b) {
	return a.score > b.score || a.score == b.score && a.id < b.id;
}
Student stu[1001];
int main()
{
	int n=0,i=0,j=0;
	cin >> n;
	for(i=1;i<=n;i++)
	cin >> stu[i].name  >> stu[i].x >> stu[i].y >> stu[i].z ;
	stu[i].id = i;
	for (i = 1; i <= (n-1); i++)
		for (j = 1; j <= (n-i); j++)
			if (isPrior(stu[j + 1], stu[j]))
			{
				swap(stu[j + 1], stu[j]);
			};
	{
		cout << stu[1].name <<" "<< stu[1].x <<" "<< stu[1].y<<" " << stu[1].z;
	}
	return 0;
}

请问还有哪里错了TAT

2024/4/29 14:28
加载中...