码迷,mamicode.com
首页 > 其他好文 > 详细

HDU1491 Octorber 21st【水题】

时间:2014-12-07 17:52:54      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   os   sp   for   

Octorber 21st


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3086    Accepted Submission(s): 1898

Problem Description
HDU‘s 50th birthday, on Octorber 21st, is coming. What an exciting day!! As a student of HDU, I always want to know how many days are there between today and Octorber 21st.So, write a problem and tell me the answer.Of course, the date I give you is always in 2006.
bubuko.com,布布扣
Input
The input consists of T test cases. The number of T is given on the first line of the input file.Following T lines, which represent dates, one date per line. The format for a date is "month day" where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31.All the date in the input are in 2006, you can assume that all the dates in the input are legal(合法).
 
Output
For each case, if the date is before Octorber 21st, you should print a number that between the date and Octorber 21st.If the day is beyond Octorber 21st, just print "What a pity, it has passed!".If the date is just Octorber 21st, print"It‘s today!!".
 
Sample Input
7
10 20
10 19
10  1
10 21
9   1
11 11
12 12
 
Sample Output
1
2
20
It‘s today!!
50
What a pity, it has passed!
What a pity, it has passed!
 
Author
8600

Source

“2006校园文化活动月”之“校庆杯”大学生程序设计竞赛暨杭州电子科技大学第四届大学生程序设计竞赛


题目大意:2006年10月21日是校庆。输入一个日期(只有月和天),如果过了校庆

间,输出What a pity, it has passed!,如果正好是校庆时间,输出:It‘s today!!,

果还没到校庆,则输出还有多少天到校庆。

思路:先判断一下是否过了时间或是正好是那一天,直接输出结果。不满足则计算

距离校庆的日子。定义一个数组存放每月天数,手算出2006年10月21天是当年第

294天,计算出输入日期是当年第几天,相减的差则为结果。


#include<stdio.h>
#include<string.h>

int main()
{
    int m[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int T,month,day;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&month,&day);
        if(month == 10 && day == 21)
            printf("It's today!!\n");
        else if(month > 10 || (month==10 && day > 21))
            printf("What a pity, it has passed!\n");
        else
        {
            int sum = day;
            for(int i = 1; i < month; ++i)
            {
                sum += m[i];
            }
            printf("%d\n",294-sum);
        }
    }

    return 0;
}




HDU1491 Octorber 21st【水题】

标签:des   style   blog   http   io   ar   os   sp   for   

原文地址:http://blog.csdn.net/lianai911/article/details/41788299

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!