Select Git revision
Forked from
Peter Gerwinski / hp
Source project has a limited visibility.
loesung-2-f1.c 613 B
#include <stdio.h>
int IsLeapYear (int year)
{
if (year % 4)
return 0;
else if (year % 100)
return 1;
else if (year % 400)
return 0;
else
return 1;
}
int main (void)
{
int ORIGINYEAR = 1980;
int days = 366;
int year;
year = ORIGINYEAR; /* = 1980 */
while (days > 365)
{
if (IsLeapYear (year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}
printf ("year = %d\ndays = %d\n", year, days);
return 0;
}