View Code of Problem 81

#include<stdio.h>
void main(){
	int a,b,c,i;
	int year=0,day=0;
	int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int mon2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	scanf("%d%d%d",&a,&b,&c);
	if((a%4==0&&a%100!=0)||(a%400==0))
		year=1;
	if(year==0){
		for(i=0;i<b-1;i++)
			day=day+mon1[i];
		day=day+c;
	}
	else{
		for(i=0;i<b-1;i++)
			day=day+mon2[i];
		day=day+c;
	}
	printf("%d",day);
}#include<stdio.h>
void main(){
	int a,b,c,i;
	int year=0,day=0;
	int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int mon2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	scanf("%d%d%d",&a,&b,&c);
	if((a%4==0&&a%100!=0)||(a%400==0))
		year=1;
	if(year==0){
		for(i=0;i<b-1;i++)
			day=day+mon1[i];
		day=day+c;
	}
	else{
		for(i=0;i<b-1;i++)
			day=day+mon2[i];
		day=day+c;
	}
	printf("%d",day);
}
/*
Main.c:2:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main(){
      ^
Main.c:21:2: error: stray '#' in program
 }#include<stdio.h>
  ^
Main.c:21:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
 }#include<stdio.h>
          ^
*/

Double click to view unformatted code.


Back to problem 81