View Code of Problem 81

#include <stdio.h>
struct time{
	int year;
	int month;
	int day;
};
int main(){
	struct time t;
	scanf("%d%d%d",&t.year,&t.month,&t.day);
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	if(t.year%4==0&&(t.year%100)!=0)
		a[1]=29;
	else if(t.year%400==0)
		a[1]=29;
	
	int sum=0;
	int i;
	for(i=0;i<t.month-1;i++){
		sum+=a[i];
	}
	sum+=t.day;
	printf("%d",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 81