【PAT甲级】1100 Mars Numbers (20 分)
题意:
输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char a[][]={"","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
char b[][]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
cin.ignore();
for(int q=;q<=n;++q){
string s;
getline(cin,s);
if(s[]>=''&&s[]<=''){
int temp=;
for(int j=;j<s.size();++j){
temp*=;
temp+=s[j]-'';
}
int x=temp/;
int y=temp%;
if(x&&y)
cout<<a[x]<<" "<<b[y]<<"\n";
else if(x)
cout<<a[x]<<"\n";
else
cout<<b[y]<<"\n";
}
else{
if(s[]==' '&&s[]!=){
char x[]={},y[]={};
for(int i=;i<;++i)
x[i]=s[i];
for(int i=;i<;++i)
y[i-]=s[i];
int pos=;
for(int i=;i<=;++i){
if(strcmp(a[i],x)==){
pos=i;
break;
}
}
int pos2=;
for(int i=;i<=;++i){
if(strcmp(b[i],y)==){
pos2=i;
break;
}
}
int temp=pos*+pos2;
cout<<temp<<"\n";
}
else if(s[]!=&&s[]==)
cout<<"0\n";
else{
char x[]={};
for(int i=;i<;++i)
x[i]=s[i];
int pos=;
for(int i=;i<=;++i)
if(strcmp(a[i],x)==){
pos=i;
break;
}
int pos2=;
for(int i=;i<=;++i)
if(strcmp(b[i],x)==){
pos2=i;
break;
}
int temp=pos*+pos2;
cout<<temp<<"\n";
}
}
}
return ;
}
【PAT甲级】1100 Mars Numbers (20 分)的更多相关文章
- PAT甲级——1100 Mars Numbers (字符串操作、进制转换)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...
- PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is de ...
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)
1046 Shortest Distance (20 分) The task is really simple: given N exits on a highway which forms a ...
- PAT 甲级 1042 Shuffling Machine (20 分)(简单题)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT甲级——1152.Google Recruitment (20分)
1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...
- PAT甲级 1120. Friend Numbers (20)
1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
随机推荐
- youtube-dl parameters
how to select the format of vidoes from youtube-dl? https://www.jianshu.com/p/611009843919 https://u ...
- linux命令 mv
后缀--backup=<备份模式>:若需覆盖文件,则覆盖前先行备份: -b:当文件存在时,覆盖前,为其创建一个备份: -f:若目标文件或目录与现有的文件或目录重复,则直接覆盖现有的文件或目 ...
- C#设置一个控件可以鼠标拖动
C#设置一个控件可以鼠标拖动: 新建一个C#项目, 创建一个label控件, 设置label的鼠标按下和抬起事件分别为:label1_MouseDown和label1_MouseUp. 对代码进行如下 ...
- linux复制,网络报错
我拷贝了过来的Linux虚拟机无法上网,我用ifconfig命令查询了一下发现只有eth1和lo设备,没有eth0.于是我在Google上搜索了一下, <VMWare克隆或复制Linux虚拟机后 ...
- C++中类成员变量的初始化问题
C++11之后允许对非静态成员变量进行初始化(in-class initialization),不过对于非fundamental(非基本数据)类型需要采用的是initializer_list来实现的 ...
- 剑指offer(leetcode 10.) 正则表达式匹配
这题一年前就做过,当时刚开始刷leetcode,提交了几十次过不去,就放那没管了.今天剑指offer又遇到这题,终于做出来了,用的dp. class Solution { public: bool i ...
- mysql update某个字段替换成某个值
UPDATE xc_admin_vehicle SET brandid= REPLACE(brandid, 19, 54) UPDATE xc_admin_models SET bid= REPLAC ...
- Java-POJ1008-Maya Calendar
题意:两种纪年方法的转换 水题,根据题目翻译成代码就可以了 居然WA了一次,避坑,output要先输出数据组数,痛心疾首啊!本来可以一次AC的. package poj.ProblemSet; imp ...
- AcWing 125. 耍杂技的牛
//按照wi+si从小到大的顺序排,结果一定最优,最大的危险系数一定是最小的 //类比于国王游戏 #include <iostream> #include <algorithm> ...
- 题解【CJOJ1236】【复赛】指数序列求和
P1236 - [复赛]指数序列求和 Description 求1^b+2^b+…+a^b的和除以10000的余数. Input 第一行包含一个正整数N,表示有N组测试数据接下来N行每行包含两个正整数 ...