View Code of Problem 81

#include<bits/stdc++.h>
using namespace std;
int isLeapYear(int year) {
	if((year%4==0&&year%100!=0) || (year%400==0)) return 1;
	else return 0;
}
int main() {
	int y,m,d,sum=0;
	int t[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>y>>m>>d;
	if(isLeapYear(y)) t[1]=29;
	for(int i=0; i<m-1; i++) sum+=t[i];
	sum+=d;
	cout<<sum;
}

Double click to view unformatted code.


Back to problem 81