PTA乙级 (*1044 火星数字 (20分))
Posted jianqiao123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PTA乙级 (*1044 火星数字 (20分))相关的知识,希望对你有一定的参考价值。
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; }
以上是关于PTA乙级 (*1044 火星数字 (20分))的主要内容,如果未能解决你的问题,请参考以下文章