View Code of Problem 81

#include <bits/stdc++.h>
using namespace std;

int m[12] = {31, 28, 31,30, 31, 30,31,31,30,31, 30,31};
int main(){
    int year, mon, day;
    cin>>year>>mon>>day;
    if((year%4==0&&year%100!=0)|| year%400==0){
        m[1] = 29;
    }
    int ans = 0;
    for(int i = 0; i<mon-1; i++){
        ans+=m[i];
    }
    cout<<ans+day<<endl;
    return 0;
}

Double click to view unformatted code.


Back to problem 81