题目:1044 火星数字 (20 分)
来源:PAT (Basic Level) Practice
题面
思路:分类讨论即可,但是细节处理上需要耗费时间。
Code
点击查看代码
#include
#include
using namespace std;
string a1[13] = { "tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec" };
string a2[13] = { "","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou" };
void f1(string s) {
int ans = 0;
for (int i = 0; i < s.size(); i++) {
ans = ans * 10 + s[i] - '0';
}
if (ans % 13==0)cout << a2[ans/13] <<"\n";
else if(ans<13)cout<>n;
// getchar();
for(int i=0;i<=n;i++) {
string s;
getline(cin, s);
if (s.size() == 4)cout << "0" << "\n";
else if (s.size() == 1 && s[0] == '0')cout << "tret" << "\n";
else if (s[0] >= '0' && s[0] <= '9') f1(s); //10->13
else f2(s); //13->10
}
return 0;
}