View Code of Problem 81

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200


int main()
{
    int y,m,d;
    int s,i;
    s=0;
    int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    scanf("%d%d%d",&y,&m,&d);
    if((y%4==0&&y%100!=0)||y%400==0)
    {
        for(i=0;i<m-1;i++)
            s+=b[i];
        s+=d;
    }
    else
    {
        for(i=0;i<m-1;i++)
            s+=a[i];
        s+=d;
    }
    printf("%d",s);


}

Double click to view unformatted code.


Back to problem 81