View Code of Problem 8

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

Double click to view unformatted code.


Back to problem 8