题意:

输入一个正整数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 分)的更多相关文章

  1. PAT甲级——1100 Mars Numbers (字符串操作、进制转换)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...

  2. PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

    1041 Be Unique (20 分)   Being unique is so important to people on Mars that even their lottery is de ...

  3. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  4. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  5. PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)

    1046 Shortest Distance (20 分)   The task is really simple: given N exits on a highway which forms a ...

  6. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  7. PAT甲级——1152.Google Recruitment (20分)

    1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...

  8. PAT甲级 1120. Friend Numbers (20)

    1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...

  9. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

随机推荐

  1. 《TCP/IP入门经典》摘录--Part 1

    TCP/IP基础知识 什么是TCP/IP Transmission Control Protocol/Internet Protocol的简写,中译名为传输控制协议/因特网互联协议,又名网络通讯协议, ...

  2. NAND FLASH驱动框架以及程序实现

    1.NAND FLASH的硬件连接: 实验用的NAND FLASH芯片为K9F2G08U0C,它是三星公司的存储芯片,它的大小为256M.它的接线图如下所示: 它的每个引脚的分别为LDATA0-LDA ...

  3. json_encode中文不转义问题

    //php5.3之后才有这个参数,这样存入数据库中的中文json数据就不会转义,也能被正确解析1JSON_UNESCAPED_UNICODE(中文不转为unicode ,对应的数字 256) JSON ...

  4. 每天一个linux命令--ssh的host配置用户名密码

    1.在终端输入 cd ~/.ssh/ vi config 输入服务器的用户名和密码 souche@kickseed:~/.ssh$ cat config # 这是跳板机的配置,给跳板机的 IP 起个别 ...

  5. String.valueOf()和toString()的区别

    1.String.valueOf(): Object obj=null; String str=""; str=String.valueOf(obj); //str=obj.toS ...

  6. 家庭记账小账本Android studio

    经过长达7天多的时间,从Android studio的安装碰到很多的问题,真的很不走运,别人安装Android studio都是一气呵成,我的Android真的没话说 把自己的这些天的开发成果展示一下 ...

  7. AcWing 4. 多重背包问题

    朴素 数据范围小 //数据范围小 #include<iostream> #include<algorithm> using namespace std ; ; int n,m; ...

  8. angularJS 十六进制与字符串相互转换

    angular 将字符串数据转换为十六进制数据 /** * @Description: TODO 字符串转16进制方法 * @author wjw * @date 2019年9月18日16:35:32 ...

  9. 磁盘分区(1):fdisk和parted

    一.Linux存储管理 关于Linux硬盘的识别: (1)如果是IDE设备,在计算机中将被识别为hd,第一个IDE设备会被识别为hda,第二个IDE设备会被识别为hdb,依此类推. (2)如果是SAT ...

  10. 【js】子菜单吸顶(滚动到一定距离 容器置顶)附 无间断置顶 避免闪动

    思考逻辑:当向上滚动的高度>= 观察容器距离顶部高度 即可触发吸顶 以下代码在vue工程,作参考 handleScroll () { const scrollTop = window.pageY ...