求救,为什么我按样例输入n=4,但主函数for循环输入3行就输出结果了
查看原帖
求救,为什么我按样例输入n=4,但主函数for循环输入3行就输出结果了
922071
libin13815498262楼主2023/2/27 01:35
#include<bits/stdc++.h>
using namespace std;
struct stu{
	int sno;
	int score1;
	int score2;
	int score3;
	int sum(){
		int a=score1;
		int b=score2;
		return a+b;
	};
};
void judge(stu a){
	if(a.sum()>140&&a.score3>=800)
	cout<<"Excellent"<<endl;
	else
	cout<<"Not excellent"<<endl;
}
int main()
{
	int n;
	cin>>n;
	stu a[n];
	for(int i=0;i<n;i++){
		cin>>a[i].score1>>a[i].score2;
		a[i].score3=a[i].score1*3+a[i].score2*7;
	}
	for(int j=0;j<n;j++){
		judge(a[j]);
	}
	return 0;
	}
2023/2/27 01:35
加载中...