View Code of Problem 8

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

int main(){
	int n,len,x,sum;
	char str[100];
	int dates[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
	//输入:1个整数n,n个字符串
	scanf("%d", &n);
	while(n--){
		sum=0;
		scanf("%s", str);
		len = strlen(str);
		x = str[len-1]-'0';
		//处理
		for(int i=0; i<12; i++){
			for(int j=1; j<=dates[i]; j++){
				if((j-1)%10!=x && (j+1)%10!=x) sum++;
			}
		}
		//输出:1个整数
		printf("%d\n", sum);
	}
	
}

Double click to view unformatted code.


Back to problem 8