题目描述
小强在统计一个小区里居民的出生年月,但是发现大家填写的生日格式不统一,例如有的人写
199808,有的人只写9808。有强迫症的小强请你写个程序,把所有人的出生年月都整理成年年年年-月月格式。对于那些只写了年份后两位的信息,我们默认小于22都是20开头的,其他都是19开头的。
输入格式:
输入在一行中给出一个出生年月,为一个 6 位或者 4 位数,题目保证是 1000 年 1 月到 2021 年 12 月之间的合法年月。
输出格式:
在一行中按标准格式
年年年年-月月将输入的信息整理输出。
输入样例 1:
9808输出样例 1:
1998-08输入样例 2:
0510输出样例 2:
2005-10输入样例 3:
196711输出样例 3:
1967-11
程序代码
#include<stdio.h>
#include<string.h>
int main(){
	char a[100000];
	scanf("%s",a);
	int x=strlen(a);
	if(x<6){
	if((a[0]-'0')*10+(a[1]-'0')<22)
	printf("20");
	else
	printf("19");
	for(int i=0;i<x;i++){
	if(i==2)
	printf("-");
	printf("%c",a[i]);
}
}
	else{
		for(int i=0;i<x;i++){
		if(i==4)
	    printf("-");
	    printf("%c",a[i]);
	}
}
	return 0;
}运行结果







![[ffmpeg系列 02] 音视频基本知识](https://img-blog.csdnimg.cn/direct/b439c2de2a6248e1a6e7eee66c84f543.png)












