题目:https://www.patest.cn/contests/pat-a-PRactise/1100
代码:
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath>#include<map>#include<string>#include<iostream>#include<algorithm> using namespace std; string a[13]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };string b[13]={"tret", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};string f[170];int main() { map<string,int> mp; for(int i=0;i<13;i++){ mp[a[i]]=i; mp[b[i]]=i*13; f[i]=a[i]; f[i*13]=b[i]; } for(int i=1;i<13;i++){ for(int j=1;j<13;j++){ string temp=b[i]+" "+a[j]; mp[temp]=i*13+j; f[i*13+j]=temp; } } int n; scanf("%d%*c",&n); while(n--){ string str; getline(cin,str); if(str[0]>='0'&&str[0]<='9'){ int num=0; for(int i=0;i<str.length();i++){ num=num*10+(str[i]-'0'); } cout<<f[num]<<endl; }else{ cout<<mp[str]<<endl; } } system("pause"); }
新闻热点
疑难解答