PAT乙级1044 火星数字 (20 分)

这是一篇关于解决PAT乙级编程题1044的博客,作者遇到了测试点34无法通过的问题,正在寻求解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://pintia.cn/problem-sets/994805260223102976/problems/994805279328157696

测试点34不过,没找到原因

#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
	string s1[13] = { "tret" ,"jan", "feb", "mar","apr","may", "jun", "jly","aug", "sep", "oct", "nov","dec" },
		s2[13] = { "tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" }
			,tmps;
	map<string, int> g, s;
	g["jan"] = 1, g["feb"] = 2, g["mar"] = 3, g["apr"] = 4, g["may"] = 5, g["jun"] = 6,
	g["jly"] = 7, g["aug"]= 8, g["sep"] = 9, g["oct"] = 10, g["nov"] = 11, g["dec"] = 12;
	s["tam"] = 1, s["hel"] = 2, s["maa"] = 3, s["huh"] = 4, s["tou"] = 5, s["kes"] = 6,
	s["hei"] = 7, s["elo"] = 8, s["syy"] = 9, s["lok"] = 10, s["mer"] = 11, s["jou"] = 12;
	int n;	cin >> n; getchar();
	for(int i = 0; i < n; i++){
		getline(cin, tmps);
		//地球文 
		if(tmps[0] >= '0' && tmps[0] <= '9'){
			int tmp1 = 0, shiwei, gewei;
			for(int j = 0; j < tmps.size(); j++)
				tmp1 = 10*tmp1 + tmps[j] - '0';
			shiwei = tmp1 / 13;
			gewei = tmp1 % 13;
			if(shiwei && gewei)	cout << s2[shiwei] << " " << s1[gewei] << endl;
			else if(shiwei && !gewei)	cout << s2[shiwei] << endl;
			else cout << s1[gewei] << endl;
		}else{//火星文 
			string s3 = "", s4 = "";
            s3 = s3 + tmps[0]+tmps[1]+tmps[2];
			if(tmps.size() > 4){
				s4 = s4 + tmps[4]+tmps[5]+tmps[6];
                cout << g[s4] + s[s3]*13 << endl;
            }
            else
			    cout << g[s3] + s[s3]*13 << endl;
		}
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值