#include<iostream>//这里只能输入一个数,怎样可以检测多个数呢?循环应该可以的!
using namespace std;//必须得加上
int main()
{
int score[4],i;
cout<<"请输入学生分数:"<<endl;
for(i=0;i<=4;i++)
cin>>score[i];
for(i=0;i<=4;i++)
{
if(score[i]>=90)
cout<<"成绩优"<<endl;
else if (score[i]>=80)
cout<<"成绩良"<<endl;
else if (score[i]>=70)
cout<<"成绩中"<<endl;
else if (score[i]>=60)
cout<<"成绩及格"<<endl;
else
cout<<"成绩不及格"<<endl;
}
return 0;
}
请输入学生分数:
79 59 95 89 67
成绩中
成绩不及格
成绩优
成绩良
成绩及格
--------------------------------
Process exited after 13.62 seconds with return value 0
请按任意键继续. . .
主要练习if else的多重嵌套,同时使用了for循环