3 2000 4 5 2001 5 4 2010 10 24
96 124 297
主要弄清闰年和平年的区别
闰年12个月:31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
平年12个月:31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
#include<cstdio> int N; int M[2][12] = {{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; bool isD(int y); int main() { int y, m, t, sum; scanf("%d", &N); while(N--) { sum = 0; scanf("%d%d%d", &y, &m, &t); if (isD(y)) { for (int i = 0; i < m-1; i++) { sum += M[0][i]; } }else { for (int i = 0; i < m-1; i++) { sum += M[1][i]; } } sum += t; printf("%d\n", sum); } return 0; } bool isD(int y) { if ((y%400 == 0)||(y%100 != 0&&y%4 == 0)) return true; return false; }