View Code of Problem 81

#include <cstdio>
#include <iostream>
using namespace std;

bool isrun(int year){
	if(year%400==0||(year%4==0&&year%100!=0))
		return true;
	return false;
}

int main(){
	int yy,mm,dd;
	cin>>yy>>mm>>dd;
	int ms[12][2]={{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}};
	bool flag=isrun(yy);
	int day=0;
	if(flag){
		for(int i=0;i<mm-1;i++){
			day+=ms[i][1]; 
		}
		day+=dd;
	}
	else{
			for(int i=0;i<mm-1;i++){
			day+=ms[i][0]; 
		}
		day+=dd;
	}
	cout<<day<<endl;
}

Double click to view unformatted code.


Back to problem 81