View Code of Problem 8

#include <stdio.h>
#include <string.h>
using namespace std;
int main(){
	
	int d[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
	int t;
	char s[100];
	scanf("%d", &t );
	while( t-- ){
		scanf("%s", &s );
		int a = s[strlen(s)-1]-'0';
		int cnt = 0;
		for( int i=0; i<12; i++ ){
			int k=1; //date
			while( k<=d[i] ){
				if( (k+1)%10 == a || (k-1)%10 == a){
					cnt ++;
				}
				k++;
			}
		}
		printf("%d\n", 365-cnt);
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 8