标签:判断 scan clu lag system int sum pre can
1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int j; 6 int year, month, day; 7 int sum = 0; //计算天数 8 int flag; //判断平年或者闰年 9 int a[][13] = { 10 {0,31,28,31,30,31,30,31,31,30,31,30,31}, 11 {0,31,29,31,30,31,30,31,31,30,31,30,31} 12 13 }; 14 15 printf("input year:month:day\n"); 16 scanf("%d%d%d",&year,&month,&day); 17 18 if(year%4==0 && year %400 !=0 || year % 400 == 0) 19 flag = 1; 20 else flag = 0; 21 22 for(j=0;j<month;j++) 23 { 24 sum += a[flag][j]; 25 } 26 sum += day; 27 28 printf("it‘s the %dth day of this year\n",sum); 29 30 system("pause"); 31 return 0; 32 33 }
标签:判断 scan clu lag system int sum pre can
原文地址:http://www.cnblogs.com/fengyp/p/7895034.html