1044 火星数字 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805279328157696
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; string str1[13]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"}; string str2[13]={"tret","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"}; string str; void fun1(int n) { if(n/13) cout<<str2[n/13]; if((n/13)&&(n%13)) cout<<" "; if((n%13)||(n==0)) cout<<str1[n%13]; } void fun2() { string s1=str.substr(0,3),s2; if(str.length()>4) s2=str.substr(4,3); int t1=0,t2=0; for(int j=1;j<=12;j++) { if((s1==str1[j])||(s2==str1[j])) t2=j; if(s1==str2[j]) t1=j; } cout<<t1*13+t2; } int main() { int N; cin>>N; getchar(); for(int i=0;i<N;i++) { getline(cin,str); if(str[0]>=‘0‘&&str[0]<=‘9‘) fun1(stoi(str)); else fun2(); cout<<endl; } return 0; }
原文地址:https://www.cnblogs.com/jianqiao123/p/12257931.html
时间: 2024-10-10 01:58:24