View Code of Problem 8

#include <iostream>
#include <cstring>
using namespace std;

int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int sum[12]={0};

int main() {
	char str[7];
	int i,j,k,count,n,t;
	for(i=0;i<10;i++){
		count=0;
		for(j=0;j<12;j++){
			for(k=1;k<=mon[j];k++){
				if(i==(k-1)%10||i==(k+1)%10)
					count++;
			}
			
		}
		
		sum[i]=365-count;
		
	}
	
	cin>>n;
	for(i=0;i<n;i++){
		
		scanf("%s",&str);
		t = str[strlen(str)-1]-'0';
		cout << sum[t] << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 8