View Code of Problem 8

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int t[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(int q = 0;q<n;q++){
		char s[20];
		getchar();
		scanf("%s",s);
		int num = s[strlen(s)-1] - '0',day = 0;
		for(int i = 1;i<13;i++){
			for(int j = 1;j<=t[i];j++){
				if((j-1 == num || j+1 == num) || ((j-1)%10 == num || (j+1)%10 == num))
					day++;
			}
		}	
		cout<<365-day<<endl;
	} 
	return 0;
} 

Double click to view unformatted code.


Back to problem 8