#include "stdio.h"
int main(int argc,char *argv[]){
int n;
printf("Please enter n(int 0<=n<=100)...\nn=");
if(scanf("%d",&n)!=1 || n<0 || n>100){
printf("Input error, exit...\n");
return 0;
}
printf("%d --> %c\n",n,n<60 ? 'D' : n<70 ? 'C' : n<85 ? 'B' : 'A');
return 0;
}
运行样例:
这个很简单啊
cout<<"请输入学生成绩:";
char buf[20];
memset(buf, 0, 20);
cin>>buf;
int num = atoi(buf);
cout<<"该学生的等次为:";
if(num < 60)
cout<<"D";
else if(num < 70)
cout<<"C";
else if(num < 85)
cout<<"B";
else
cout<<"A";
cout<