Feown


私信TA

用户名:uq_13516770928

访问量:4438

签 名:

等  级
排  名 3489
经  验 1836
参赛次数 0
文章发表 21
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<iostream>
#include<string>
#include<set>;
using namespace std;
int dir[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s;
set<int> se;
int year, month, day;
int ff = 0;
int run(int y){
	if(y % 400 == 0 || y % 4 == 0 && y % 100 != 0){
		return 1;
	}
	return 0;
}
int check(int y, int m, int d){
	if(run(y)){
		ff = 1;
		dir[2]++;
	}
	if(m > 0 && m <= 12 && d > 0 && d <= dir[m]){
		return 1;
	}
	return 0;
}
void f(int y, int m, int d){
	if(check(y, m, d)){
		if(y >= 60){
			y = 1900 + y;
		} else {
			y = 2000 + y;
		}
		int x = y * 10000 + m * 100 + d;
		se.insert(x);
	}
	if(ff){
		dir[2]--;
		ff = 0;
	}
}
int main(){
	cin>>s;
	year = ((int)(s[0]) - 48) * 10 + ((int)(s[1]) - 48);
	month = ((int)(s[3]) - 48) * 10 + ((int)(s[4]) - 48);
	day = ((int)(s[6]) - 48) * 10 + ((int)(s[7]) - 48);
	f(year, month, day);
	f(day, year, month);
	f(day, month, year);
	for(set<int>::iterator it = se.begin(); it != se.end(); it++){
		int y = *it / 10000;
		int m = *it / 100 % 100;
		int d = *it % 100;
		printf("%d-%02d-%02d\n", y, m, d);
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区