这一题纠结过要不要传
因为之前传过杭电版的
不过鉴于被这个稍微改一下的坑了一下
而且主要是标程写的不错
所以就传一下吧
#include<stdio.h>
int main() {
int T;
scanf("%d",&T);
while(T--) {
int n;
scanf("%d",&n);
if(n<60)
printf("E
");
if(n>=60&&n<70)
printf("D
");
if(n>=70&&n<80)
printf("C
");
if(n>=80&&n<90)
printf("B
");
if(n>=90&&n<=100)
printf("A
");
}
return 0;
}
标程的一个除法配合switch就巧妙地写出了条件
#include<iostream>
using namespace std;
int main() {
int n,s;
cin>>n;
while(n--) {
cin>>s;
switch(s/10) {
case 10:
case 9:
cout<<"A"<<endl;
break;
case 8:
cout<<"B"<<endl;
break;
case 7:
cout<<"C"<<endl;
break;
case 6:
cout<<"D"<<endl;
break;
default:
cout<<"E"<<endl;
break;
}
}
}
题目地址:【NYOJ】[98]成绩转换