标签:
/*题目:输入某年某月某日,判断这一天是这一年的第几天?*/ /*把这几个月份加起来再加上这个天数*/ #include<stdio.h> #define ER(a) ((a)%4==0&&(a)%100!=0||(a)%400==0) #define N 12 int main(void) { struct int_year { int year; int moon; int day; } num; scanf("%d%d%d", &num.year, &num.moon, &num.day); if(num.moon==12) num.moon = 0; int year[N] = {31,28+ER(num.year),31,30,31,30,31,31,30,31,30,31}; int daynum, i; daynum = i = 0; for(i=0;i<num.moon;i++) daynum += year[i]; printf("%d年%d月%d日是这一年的第%d天\n", num.year, num.moon==0 ? 12 : num.moon, num.day, daynum+num.day); return 0; }
标签:
原文地址:http://my.oschina.net/dengwo/blog/477396