View Code of Problem 81

#include <stdio.h>
#include <stdlib.h>
struct date{
	int year;
	int month;
	int day;
}d;

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

Double click to view unformatted code.


Back to problem 81