View Code of Problem 81

#include<stdio.h>
#include<stdlib.h>

int Day(int month){
	int m;
	switch(month){
			case 1:m=0;
			case 2:m=31;
			case 3:m=59;
			case 4:m=90;
			case 5:m=120;
			case 6:m=151;
			case 7:m=181;
			case 8:m=212;
			case 9:m=243;
			case 10:m=273;
			case 11:m=304;
			case 12:m=334;
			default :break;	
		}
	return m;
}

int main(){
	int year,month,day,m;
	scanf("%d %d %d",&year,&month,&day);
	if(year%4==0){
		if(year%200==100){
			 printf("%d",Day(month)+day);
		}
		else{
			if(month<3)printf("%d",Day(month)+day);
			else printf("%d",Day(month)+day+1);
		} 
	}
	else{
		printf("%d",Day(month)+day);
	} 
} 

Double click to view unformatted code.


Back to problem 81