0
点赞
收藏
分享

微信扫一扫

实验7-2-4 计算天数 (15分)


实验7-2-4 计算天数 (15分)_#include

#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分)_c语言_02


举报

相关推荐

0 条评论