在这里#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int month[13][2] = { (0, 0), (31, 31), (28, 29), (31, 31), (30, 30), (31, 31),
(30, 30), (31, 31), (30, 30), (31, 31), (30, 30), (31, 31), (30, 30) };//平年和闰年每月的天数
bool isleap(int year){
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int main(){
int time1, y1, m1, d1;
int time2, y2, m2, d2;
scanf_s("%d%d", &time1, &time2);
if (time1 > time2){
int temp = time1;
time1 = time2;
time2 = temp;
}
y1 = time1 / 10000, m1 = time1 % 10000 / 100, d1 =time1% 100;
y2 = time2 / 10000, m2 = time2 % 10000 / 100, d2 =time2% 100;
int ans = 1;//记录结果
while (y1 < y2 || m1 < m2 || d1 < d2){
d1++;
if (d1 == month[m1][isleap(y1)] + 1){
m1++;
d1 = 1;
}
if (m1 == 13){
y1++;
m1 = 1;
}
ans++;
}
printf("%d", ans);
system("pause");
return 0;
}插入代码片
07-16
5627
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-13
3678
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交