View Code of Problem 8

#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
		int n;
		scanf("%d", &n);
		char str[100];
		int sum = 0;
		int day[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
		while (n--) {
			scanf("%s", str);
			
			int len = strlen(str);
			int k = str[len - 1] - '0';
			for (int i = 0; i < 12; i++) {
				for (int j = 1; j <= day[i]; j++) {
					if ((j + 1) % 10 == k || (j - 1) % 10 == k) {
						sum++;
					}
				}
			}
			std::cout << 365 - sum << endl;
			sum = 0;

		}
}

Double click to view unformatted code.


Back to problem 8