#include<iostream>
using namespace std;
int main()
{
int grad;
cout<<"请输入你要查询的成绩:"<<endl;
cin>>grad;
if(grad>100)
cout<<"您输入的数据错误";
else if(grad>=90&&grad<=100)
cout<<"A";
else if(grad>=80&&grad<90)
cout<<"B";
else if(grad>=70&&grad<80)
cout<<"C";
else if(grad>=60&&grad<70)
cout<<"D";
else
cout<<"E";
}
————————————————————————————————————
嵌套的语句——查询成绩
#include<iostream>
using namespace std;
int main()
{
int grad;
cout<<"请输入你要查询的成绩:"<<endl;
cin>>grad;
if(grad>100||grad<0)
cout<<"您输入的数据错误";
else if(grad<60)
cout<<"E";
else
{
if(grad<70)
cout<<"D";
else
{
if(grad<80)
cout<<"C";
else
{
if(grad<90)
cout<<"B";
else
cout<<"A";
}
}
}
}