View Code of Problem 8

#include<iostream>
using namespace std;
int main()
{
    char s[100];
    char month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int days=365;
        scanf("%s",s);
        int j=0;
        while(s[j]!='\0')
        {
            j++;
        }
        int num=s[j-1]-'0';
        for(int i=1;i<=12;i++)
        {
            for(int j=1;j<=month[i];j++)
            {
                if((j%10)==(num+10-1)%10||(j%10)==(num+10+1)%10)
                    days--;
            }
        }
        cout<<days<<endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 8