样例输入
2 8
样例输出
Feb08
样例输入
10 18
样例输出
Oct18
打个月份字符串数组
string m[13]={" ","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
#include<bits/stdc++.h>
using namespace std;
string m[13]={" ","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
int main(){
int a,b;
scanf("%d %d",&a,&b);
cout<<m[a];
printf("%02d",b);
return 0;
}
拓展:
输入输出反过来时:
#include<bits/stdc++.h>
using namespace std;
string m[13]={" ","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
int main(){
string s;
cin>>s;
//s:Feb01 s1:Feb s2:01
string s1=s.substr(0,3);
for(int i=1;i<=12;i++){
if(s1==m[i]){
cout<<i<<" ";
}
}
string s2=s.substr(3,2);
if(s2[0]=='0'){
cout<<s2[1];
}
else{
cout<<s2;
}
return 0;
}