hdu 1491

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1491

题意:给一个2006年的日期,问和2006年10月21日还差几天。

mark:getdays是用于获得m月d日是当年的第几天。最后和10月21日做比较。

代码:

# include <stdio.h>


int getdays (int m, int d)
{
int i, rtn = 0, month [12] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30} ;
for (i = 0 ; i < m ; i++)
rtn += month[i] ;
return rtn + d ;
}


int main ()
{
int T ;
int days, target, m, d ;
scanf ("%d", &T) ;
target = getdays (10, 21) ;
while (T--)
{
scanf ("%d %d", &m, &d) ;
days = getdays (m, d) ;
if (days > target) puts ("What a pity, it has passed!") ;
else if (days == target) puts ("It's today!!") ;
else printf ("%d\n", target - days) ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2316261.html