航电oj2004-2005代码

题目--2004

输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下:

90~100为A; 80~89为B;

70~79为C; 60~69为D;

0~59为E;

Input

输入数据有多组,每组占一行,由一个整数组成。

Output

对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Score is error!”。

#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{

int score;
while(scanf("%d",&score)!=EOF)
{
    getchar();
    if(score > 100 || score < 0)
    {
        printf("Score is error!\n");
        continue;
    }
    score = score / 10;
    switch(score)
    {
    case 10:
    case 9:
        printf("A\n");
        break;
    case 8:
        printf("B\n");
        break;
    case 7:
        printf("C\n");
        break;
    case 6:
        printf("D\n");
        break;
    default:
        printf("E\n");
        break;
    }
}
return 0;

}

题目--2005

Problem Description

给定一个日期,输出这个日期是该年的第几天。

Input

输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。

Output

对于每组输入数据,输出一行,表示该日期是该年的第几天。

#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{

int year,month,day,date,i;
int days[2][12] = {{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}};
while(scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
    getchar();
    //判断是否是闰年
    date = day;
    if((year % 4==0 && year % 100!=0)||year % 400==0)
    {
        for(i=0; i<month-1; i++)
        {
            date += days[1][i];
        }
        printf("%d\n",date);
    }
    else
    {
        for(i=0; i<month-1; i++)
        {
            date += days[0][i];
        }
        printf("%d\n",date);
    }
}
return 0;

}

猜你喜欢

转载自blog.51cto.com/14221754/2630743