计算天数

xiaoxiao2021-02-28  91

题目描述

输入年月日,计算该填是本年的第几天。例如1990 20 日是1990 年的第263 天,

2000 日是2000 年第122 天。(闰年:能被400 正除,或能被整除但不能被100

整除。每年1357810 为大月)

输入

输入第一行为样例数m,接下来m行每行3个整数分别表示年月日。

输出

输出m行分别表示题目所求

#include <stdio.h> int dayOfMonth[13] = {0,31,60,91,121,152,182,213,244,274,305,335,366}; int main() { int m,year,month,date; scanf("%d\n",&m); int count=0; while (scanf("%d %d %d\n",&year,&month,&date)!=EOF) { count++; if(year%4 == 0 && year0 !=0 || year@0 == 0) { if(month<=2) printf("%d\n",(month-1)*31+date); if (month>2) { int total= dayOfMonth[month-1]+date; printf("%d\n",total ); } } else { if(month<=2) printf("%d\n",(month-1)*31+date); if (month>2) { int total= dayOfMonth[month-1]+date-1; printf("%d\n",total ); } } if(count==m) break; } return 0; } //闰年 29 天 ;平年 28天

转载请注明原文地址: https://www.6miu.com/read-76397.html

最新回复(0)