View Code of Problem 81

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;


int main()
{
    int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int year,mon,day;
    int count = 0;
    scanf("%d %d %d",&year,&mon,&day);
    if((year % 4 == 0 && year % 100 !=0) || (year % 100 ==0 && year % 400 ==0))
    {
        month[1] = 29;
    }
    for(int i=0;i<mon-1;i++)
    {
        count = count + month[i];
    }
    count = count + day;
    printf("%d\n",count);
    return 0;
}

Double click to view unformatted code.


Back to problem 81