3 回答
TA贡献97条经验 获得超118个赞
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
struct Student
{
string name;
double acct;
double score;
};
int main()
{
Student students[10];
int counts=0;
int countA=0;
int countB=0;
int countC=0;
int countD=0;
for(int i=0;i<10;i++)
{
cout<<"Enter students"<<i+1<<" name : "<<endl;
getline(cin,students[i].name);
cout<<"Enter students"<<i+1<<" acct: "<<endl;
cin>>students[i].acct;
cout<<"Enter students"<<i+1<<" score: "<<endl;
cin>>students[i].score;
while(cin.get()!='\n')
continue;
}
for(int i=0;i<10;i++)
{
if(students[i].score<60)
countD++;
else if(students[i].score<70)
countC++;
else if(students[i].score<80)
countB++;
else if(students[i].score<90)
countA++;
else
counts++;
}
cout<<"not pass: "<<countD<<endl;
cout<<"60~70: "<<countC<<endl;
cout<<"70~80: "<<countB<<endl;
cout<<"80~90: "<<countA<<endl;
cout<<"90~100: "<<counts<<endl;
system("pause");
return 0;
}
简单来说估计就是这样。
如果要求输出每个学生的等级稍微修改一下就可以了。
- 3 回答
- 0 关注
- 1341 浏览
添加回答
举报