求大佬告知哪里出了错
本帖最后由 带上面具的孩纸 于 2019-1-7 02:05 编辑捋了好几次没找出毛病 拜托了大佬 #include<stdio.h>
#include<stdlib.h>
int main()
{
long sum = 0;
int year1, year2;
int month1, month2;
int day1, day2;
int days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
printf("请输入生日");
scanf_s("%d%d%d", &year1, &month1, &day1);
printf("请输入当前日期");
scanf_s("%d%d%d", &year2, &month2, &day2);
while (year1 <= year2)
{
days = (year1 % 400 == 0 || (year1 % 4 == 0 && year1 % 100 != 0)) ? 29 : 28;
while (month1 <= 12)
{
while (day1 <= days)
{
if (year1 == year2 && month1 == month2 && day1 == day2)
{
goto FINSH;
}
day1 ++;
sum++;
}
day1 = 1;//每月第一天是1号;
month1++;
}
month1 = 1;//days索引已经减一了,month从1开始;
year1++;
}
FINSH:printf("你在世上苟活了%d天\n", sum);
system("pause");
return 0;
} Mountain_gs 发表于 2019-1-7 11:11
感谢感谢
页:
[1]