算出来数据不同
我计算出来 是10536天 , 小甲鱼算出来是101**天。 有悬殊,是为什么#include <stdio.h>
int main()
{
long long count = 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("请输入你的生日(如1988-05-20):");
scanf("%d-%d-%d", &year1, &month1, &day1);
printf("请输入今年日期(如2016-03-28):");
scanf("%d-%d-%d", &year2, &month2, &day2);
for (year1; year1 <= year2; year1++)
{
days = (year1 % 400 == 0 || (year1 % 4 == 0 && year1 % 100 != 0)) ? 29 : 28;
for (month1; month1 <= 12; month1++)
{
for (day1; day1 <= days; day1++)
{
if (year1 == year2 && month1 == month2 && day1 == day2)
{
goto FINISH;
}
count++;
}
day1 = 0;
}
month1 = 0;
}
FINISH: printf("你在这个世界上总共生存了%lld天\n", count);
getchar();
return 0;
} @qq1242009750 @BngThea @燃烧的水帮帮忙 题目是 带你学C带你飞的 S1E17-1。 输入的值不一样,结果当然不一样 BngThea 发表于 2017-12-7 22:03
输入的值不一样,结果当然不一样
我输入的值一摸一样,但是结果有点小小悬殊。是为什么
页:
[1]