社区讨论

c++不知哪错了

B2125最高分数的学生姓名参与者 7已保存回复 13

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
13 条
当前快照
1 份
快照标识符
@lo3gno2s
此快照首次捕获于
2023/10/24 06:19
2 年前
此快照最后确认于
2023/10/24 06:19
2 年前
查看原帖
CPP
#include<iostream>
using namespace std;
struct student
{
	string name;
	int score;
};
int main()
{
	int n,max=0,t=1;
	scanf("%d",&n);
	student stu[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%d%s",stu[i].score,stu[i].name.c_str());
		if(stu[i].score>max)
		{
			max=stu[i].score;
			t=i;
		}
	}
	printf("%s",stu[t].name.c_str());
	return 0;
}

回复

13 条回复,欢迎继续交流。

正在加载回复...