View Code of Problem 8

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int cmp(const void *a , const void *b){
    return  ((int *)a) - ((int *)b);
}
 
int main()
{
    int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int N;
    scanf("%d",&N);
    while(N){
        N--;
        char s[100];
        scanf("%s",s);
        int count = strlen(s);
        int num = 0;
        int n = s[count-1] - '0';
        for (int i = 0; i < 12; i++)
        {
            for(int j = 1; j<=month[i];j++){
                if((j+1)%10 == n || (j-1)%10 == n){
                    num ++;
                }
            }
        }
        printf("%d\n",365 - num);
        
 
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 8