首页 > 其他 > 详细

PTA乙级 (*1044 火星数字 (20分))

时间:2020-02-03 23:16:26      阅读:86      评论:0      收藏:0      [点我收藏+]

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分))

原文:https://www.cnblogs.com/jianqiao123/p/12257931.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!