View Code of Problem 8

#include<stdio.h>  
#include<string.h>  
int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};  
int num[12]={0};  
int main()  
{  
    char str[12]={0};  
    int n,i,j,cnt,k,t;  
    for(i=0;i<10;i++)  
    {  
        cnt=0;  
        for(j=0;j<12;j++)  
        {  
            for(k=1;k<=mon[j];k++)  
            {  
                if(i==(k-1)%10||i==(k+1)%10)  
                cnt++;  
            }  
        }  
        num[i]=365-cnt;  
    }  
    scanf("%d",&n);  
        for(i=0;i<n;i++)  
        {  
            getchar();  
            scanf("%s",str);  
            t=str[strlen(str)-1]-'0';  
            printf("%d\n",num[t]);  
        }  
    return 0;  
}  

Double click to view unformatted code.


Back to problem 8