View Code of Problem 8

#include<iostream>
#include<cmath>
#include<cstdio>
#include <string>
using namespace std;

int days(int m) {
	/*int d1, d2, d3;
	d1 = 0;
	d2 = 0;
	d3 = 0;
	if (m == 0)
		return 287;
	else if (m == 9)
		return 294;
	else {
		for (int i = 1; i <= 28; i++) {
			if (m - i % 10 != 1 && m - i % 10 != -1) {
				d1++;
			}
		}
		for (int i = 1; i <= 30; i++) {
			if (m - i % 10 != 1 && m - i % 10 != -1) {
				d2++;
			}
		}
		for (int i = 1; i <= 31; i++) {
			if (m - i % 10 != 1 && m - i % 10 != -1) {
				d3++;
			}
		}
		int d;
		d = d1 + 4 * d2 + 7 * d3;*/
		//cout << d1 <<" "<< d2<<" " << d3;
	int a[11] = { 287,294,286,293,293,293,285,293,293,293 };
	return a[m];
	
}


int main() {
	int n;
	char data[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> data;
		cout << days(data[7] - '0');
	}
	
	return 0;
}	

Double click to view unformatted code.


Back to problem 8