日期问题

2022-06-28 19:00:03 浏览数 (1)

本文最后更新于 1163 天前,其中的信息可能已经有所发展或是发生改变。

代码语言:javascript复制
#include<iostream>
#include<cstring>
using namespace std;
int arr_num[3][2];
int arr_final[3];
void dg(int step){
	if(step==3){
		for(int i=0;i<3;i  ){
			cout<<arr_final[i]<<" ";
		}
		cout<<endl;
		if(arr_final[0]>59){
			cout<<"19"<<arr_final[0]<<"-";			
		}else{
			if(arr_final[0]>9){
				cout<<"20"<<arr_final[0]<<"-";	
			}else{
				cout<<"200"<<arr_final[0]<<"-";	
			}
		}
		if(arr_final[1]>9){
			cout<<arr_final[1]<<"-";
		}else{
			cout<<"0"<<arr_final[1]<<"-";
		}
		if(arr_final[2]>9){
			cout<<arr_final[2]<<endl;
		}else{
			cout<<"0"<<arr_final[2]<<endl;
		}
		return;
	}
	for(int i=0;i<3;i  ){
		if(arr_num[i][1]==0){
			arr_num[i][1]=1;
			arr_final[step]=arr_num[i][0];
			dg(step 1);
			arr_num[i][1]=0;
			arr_final[step]=0;
		}
	}
}
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
int monthR[]={31,29,31,30,31,30,31,31,30,31,30,31};
void judge(int a,int b,int c){
	if(a%4==0){
		if(0<b&&b<=12){
			if(c<=monthR[b]){
				
				if(a>59){
					cout<<"19"<<a<<"-";			
				}else{
					if(a>9){
						cout<<"20"<<a<<"-";	
					}else{
						cout<<"200"<<a<<"-";	
					}
				}
				if(b>9){
					cout<<b<<"-";
				}else{
					cout<<"0"<<b<<"-";
				}
				if(c>9){
					cout<<c<<endl;
				}else{
					cout<<"0"<<c<<endl;
				}
				
				
			}
		}
	}else{
		if(0<b&&b<=12){
			if(c<=month[b]){
				
				if(a>59){
					cout<<"19"<<a<<"-";			
				}else{
					if(a>9){
						cout<<"20"<<a<<"-";	
					}else{
						cout<<"200"<<a<<"-";	
					}
				}
				if(b>9){
					cout<<b<<"-";
				}else{
					cout<<"0"<<b<<"-";
				}
				if(c>9){
					cout<<c<<endl;
				}else{
					cout<<"0"<<c<<endl;
				}
				
				
			}
		}
	}
	
}
int main(){
	char arr[8];
	cin>>arr;
	memset(arr_num,0,sizeof(arr_num));
	memset(arr_final,0,sizeof(arr_final));
	int a,b,c;
	a=(arr[0]-'0')*10 (arr[1]-'0');
	b=(arr[3]-'0')*10 (arr[4]-'0');
	c=(arr[6]-'0')*10 (arr[7]-'0');
	judge(a,b,c);
	judge(c,a,b);
	judge(c,b,a);
	
	
	
	//dg(0);
	return 0;
}

Post Views: 195

0 人点赞