View Code of Problem 8

#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
//2014年的2月 28天 一共365天 
//为啥啊,为啥这个oj的题目这么难懂,我真无语了,浪费时间,语义不明 
//日期+1mod尾号 
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
int dayforcar[10]={0};

void printday(){
	for(int k=0;k<10;k++){
		int count=0;//不能走的日子 
		for(int i=0;i<12;i++){
			for(int j=1;j<=month[i];j++){//日期 
				if((j+1)%10==k||(j-1)%10==k){//如果今天的余数+1碰上这个尾号,或者减一碰上这个尾号 
					count++; //这个日子这个尾号不能走++ 
				}			
			}
		}
		dayforcar[k]=365-count; 
	}

} 
int main(){
	int n;
	cin>>n;
	printday();
	for(int i=0;i<n;i++){
		string ss;
		cin>>ss;
		int len=ss.length();
		int one=stoi(ss.substr(len-1,1));
		
		cout<<dayforcar[one]<<endl;	
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 8