题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1491

7 10 20 10 19 10 1 10 21 9 1 11 11 12 12
1 2 20 It‘s today!! 50 What a pity, it has passed! What a pity, it has passed!
代码如下:
#include <cstdio>
int mon(int x)
{
if(x == 1)
return 31;
else if(x == 2)
return 28;
else if(x == 3)
return 31;
else if(x == 4)
return 30;
else if(x == 5)
return 31;
else if(x == 6)
return 30;
else if(x == 7)
return 31;
else if(x == 8)
return 31;
else if(x == 9)
return 30;
}
int main()
{
int t;
int m, d;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&m,&d);
if(m == 10 && d == 21)
{
printf("It's today!!\n");
continue;
}
if(m>10 ||(m==10&&d>21))
{
printf("What a pity, it has passed!\n");
continue;
}
int sum = 0;
for(int i = m; i < 10; i++)
{
sum+=mon(i);
}
printf("%d\n",sum-d+21);
}
return 0;
}
原文地址:http://blog.csdn.net/u012860063/article/details/39201991