View Code of Problem 8

#include<stdio.h>
#include<math.h>
#include<string.h>
int main() {
	int sum, time, tail, N, i, k, j, a[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	char x[100];
	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%s",x);
		sum = 0;
		tail = x[strlen(x) - 1] - '0';
		for (k = 0; k < 12; k++) {
			for (j = 1; j <= a[k]; j++) {
				if ((j + 1) % 10 != tail && (j - 1) % 10 != tail) {
					sum++;
				}
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 8