View Code of Problem 81

#include <stdio.h>
struct Date
{
	int year;
	int month;
	int day;
};
int main()
{
	struct Date date;
	scanf("%d%d%d", &date.year, &date.month, &date.day);
	int mon[] = {0, 31,28,31,30,31,30,31,31,30,31,30,31 };
	int sum = 0,i;
	for (i = 0; i < date.month; i++)
		sum += mon[i];
	sum += date.day;
	if ((date.year % 4 == 0 && date.year % 100 != 0) || (date.year % 400 == 0))
		sum++;
	printf("%d\n", sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 81