1412 - C语言-分数换算

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

给出一百分制成绩,要求输出成绩等级‘A’、‘B’、‘C’、‘D’、‘E’。 90分以上为A 80-89分为B 70-79分为C 60-69分为D 60分以下为E

题目输入

一个整数0-100以内

题目输出

一个字符,表示成绩等级

输入/输出样例

输入格式

90

输出格式

A

C语言解答

#include<stdio.h>
void main()
{
	int score;
	char ans;
	scanf("%d",&score);
	if(90<=score)
		ans='A';
	else if(80<=score&&score<90)
		ans='B';
	else if(70<=score&&score<80)
		ans='C';
	else if(60<=score&&score<70)
		ans='D';
	else
		ans='E';
	printf("%c\n",ans);
}

C++解答

#include<iostream>
#include<iomanip>
#include<fstream>
#include<string> 
#include<climits>
#include<cctype>
#include<cmath>
#include<cstring>
using namespace std;

int main()
{
 //ifstream cin("aaa.txt");
  int i,j,n,m,k,sum,p,len,a[10001],l,count;
  
  int x,y;
  string s,b[1000];
  cin>>x;
  if(x>=90) cout<<'A';
  else if(x>=80) cout<<'B';
  else if(x>=70) cout<<'C';
  else if(x>=60) cout<<'D';
  else cout<<'E';
  

  	return 0;

}