zoukankan      html  css  js  c++  java
  • 1491 Octorber 21st

    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.

     
    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!
     1 #include <iostream>
     2 #include <algorithm>
     3 #include <stdio.h>
     4 #include <math.h>
     5 #include <string.h>
     6 #include <time.h>
     7 using namespace std;
     8 
     9 int main()
    10 {
    11     int n,m,t,s;
    12     while(cin>>t)
    13     {
    14         while(t--)
    15         {
    16             cin>>n>>m;
    17             if(n>=1&&n<=12)
    18             s=0;
    19             if(n<10)
    20             {
    21                    for(int i=n;i<10;i++)
    22                    {
    23                        if(i==1||i==3||i==5||i==7||i==8)
    24                        s=s+31;
    25                        else if(i==2)
    26                        s=s+28;
    27                        else
    28                        s=s+30;
    29                    }
    30                    s=s+21-m;
    31             }
    32             else if(n==10)
    33             {
    34                 if(m<21)
    35                 s=s+21-m;
    36                 else if(m==21)
    37                 s=-1;
    38             }
    39             if(s>0)
    40             cout<<s<<endl;
    41             else if(s==-1)
    42             cout<<"It's today!!"<<endl;
    43             else
    44             cout<<"What a pity, it has passed!"<<endl;
    45         }
    46     }
    47     return 0;
    48 }
    View Code
  • 相关阅读:
    客户端验证用户名和密码
    特殊日期提示
    python 多态这一部分的知识点相关应用
    类的继承
    栈,队列的应用
    生成器与for循环的纠葛
    类(class)的形成过程
    报错信息看着哇
    死脑筋要活用(我只放贴图)01
    正则运算跟py语言的结合,知识点层出不穷
  • 原文地址:https://www.cnblogs.com/wang-ya-wei/p/5265681.html
Copyright © 2011-2022 走看看