#include <stdio.h>
int main()
{
int result, year, month, day, flag = 0;
scanf("%d/%d/%d", &year, &month, &day);
if (year%400 == 0 || year%4 == 0 && year%100 != 0)
flag = 1;
if (month == 1){
result = day;
}else if( month == 2){
result = 31 + day;
}else if( month == 3){
result = 31 + 28+ day;
}else if( month == 4){
result = 31 + 28 + 31 + day;
}else if( month == 5){
result = 31 + 28 + 31 + 30 + day;
}else if( month == 6)
result = 31 + 28 + 31 + 30 + 31 + day;
else if( month == 7)
result = 31 + 28 + 31 + 30 + 31 + 30 + day;
else if( month == 8)
result = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
else if( month == 9)
result = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
else if( month == 10)
result = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
else if( month == 11)
result = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
else if( month == 12)
result = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
if(flag && month != 1 && month != 2)
result += 1;
printf("%d", result);
return 0;
}
实验7-2-4 计算天数 (15分)
最新推荐文章于 2020-12-15 14:46:36 发布