1. 程式人生 > >杭電ACM2004題(成績轉換)-----C語言

杭電ACM2004題(成績轉換)-----C語言

成績轉換

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 124199    Accepted Submission(s): 54496


Problem Description 輸入一個百分制的成績t,將其轉換成對應的等級,具體轉換規則如下:
90~100為A;
80~89為B;
70~79為C;
60~69為D;
0~59為E;

Input 輸入資料有多組,每組佔一行,由一個整陣列成。
Output 對於每組輸入資料,輸出一行。如果輸入資料不在0~100範圍內,請輸出一行:“Score is error!”。
Sample Input 56 67 100 123
Sample Output E D A Score is error!
#include<stdio.h>
int main ()
{
    int t;
    while (scanf("%d",&t)!=EOF)
    {
        if(90<=t&&t<=100)printf("%c\n",'A');
        else if(80<=t&&t<=89)printf("%c\n",'B');
        else if(70<=t&&t<=79)printf("%c\n",'C');
        else if(60<=t&&t<=69)printf("%c\n",'D');
        else if(0<=t&&t<=59)printf("%c\n",'E');
        else printf("Score is error!\n");
    }
    return 0;
}