View Code of Problem 81

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

Double click to view unformatted code.


Back to problem 81