View Code of Problem 8

#include<stdio.h>
#include<string.h>

int main(void)
{
	int t;
	scanf("%d",&t);
	int mon[12]={1,2,3,4,5,6,7,8,9,10,11,12};
	int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int s[10];
		for(int i=0;i<10;i++)
		{
			int sum=365,count=0;
			for(int j=0;j<12;j++)
			{
				for(int k=1;k<=day[j];k++)
				{
					if((k-i-1)%10==0||(k-i+1)%10==0)
					{
						count++;
					}
				}
			}
			s[i]=sum-count;
		}
	while(t--)
	{
		int n,m;char c[20];
		scanf("%s",&c);
		m=c[strlen(c)-1]-'0';
		if(t==1)
		{
			printf("%d",s[m]);
		}
		else
		{
			printf("%d\n",s[m]);
		}
	}		
}

Double click to view unformatted code.


Back to problem 8