View Code of Problem 81

#include<iostream>
#include<cstring>
#include<string.h>
using namespace std;
int month[13][2] = {{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31}
,{30,30},{31,31},{30,30},{31,31}};
int p(int);
int main(){
	int year,m,d;
	cin>>year>>m>>d;
	int sum = 1,t = 1;
	int flag = p(year);
	for(int i = 1;i<=m;i++){
		if(i!=m){
			sum = sum + month[i][flag];
		}else{
			int op = 1;
			while(op < d){
				sum++;
				op++;
			}
		}
	}

	
	
	cout<<sum;
	return 0;
} 
int p(int n){
	if(n%400 == 0 || (n%4==0 && n%100!=0))return 1;
	else return 0;
}

Double click to view unformatted code.


Back to problem 81