View Code of Problem 8

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

Double click to view unformatted code.


Back to problem 8