View Code of Problem 81

#include<iostream>

using namespace std;

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

int main(){
	int month[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int y;
	int m;
	int d;
	cin>>y>>m>>d;
	if(isLeapYear(y)){
		month[2]=29;
	}
	int sum=0;
	for(int i=1;i<m;++i){
		sum+=month[i];
	}
	sum+=d;
	cout<<sum;
	return 0;
}

Double click to view unformatted code.


Back to problem 81