View Code of Problem 81

#include<stdio.h>
void main()
{
    struct day
    {
        int year;
        int month;
        int date;
    }d;
    scanf("%d%d%d",&d.year,&d.month,&d.date);
    int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int i,days=0;
    if ((d.year%400==0)||(d.year%100!=0)&&(d.year%4==0)) m[1]++;
    for(i=0;i<d.month-1;i++)
        days+=m[i];
    days+=d.date;
    printf("%d\n",days);
}

Double click to view unformatted code.


Back to problem 81