View Code of Problem 8

#include<stdio.h>
#include<string.h>
int main()
{
	int T, i, j, x, num, num1;
	char a[100];
	scanf("%d", &T);
	for (i = 0; i < T; i++)
	{
		num = 0;
		num1 = 0;
		scanf("%s", a);
		x = a[strlen(a) - 1] - '0';
		if (x == 0)
		{
			printf("287\n");
		}
		if (x == 9)
		{
			printf("294\n");
		}
		if (x == 2)
		{
			printf("286\n");
		}
		if(x!=9&&x!=0&&x!=2)
		{
			for (j = 1; j <= 31; j++)
			{
				if (j % 10 - 1 == x || j % 10 + 1 == x)
				{
					num++;
				}
			}
			num = num * 6;
			for (j = 1; j <= 28; j++)
			{
				if (j % 10 - 1 == x || j % 10 + 1 == x)
				{
					num++;
				}
			}
			for (j = 1; j <= 30; j++)
			{
				if (j % 10 - 1 == x || j % 10 + 1 == x)
				{
					num1++;
				}
			}
			num1 = num1 * 5;
			num = num + num1;
			printf("%d\n", 365 - num);
		}
	}
}

Double click to view unformatted code.


Back to problem 8