【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 ...
随机推荐
- [LOJ144] DFS 序 1 - DFS序 线段树
为熟悉机房键盘而划水 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 4 ...
- 使用tableExport.js直接导出web页面上的table
1,需要导入两个js文件,一个tableExport.js,另一个是jquery.base64.js,前一个文件是导出数据和核心类库,后一个是为了避免导出中文时乱码的js文件,如果你导出的数据没有中文 ...
- Python之路【第三十二篇】:django 分页器
Django的分页器paginator 文件为pageDemo models.py from django.db import models # Create your models here. cl ...
- Layui之动态循环遍历出的富文本编辑器显示
这篇记得是工作中的例子 描述: 平常的富文本显示都是根据静态的html获取id来显示,比如: <textarea class="layui-textarea" id=&quo ...
- java 数字转换格式化
1.小数格式化后转字符串百分数(带%)输出 NumberFormat nt = NumberFormat.getPercentInstance(); //设置百分数精确度2即保留两位小数 nt.set ...
- node安装升级过程中遇到的问题汇总
一.Node already installed, it's just not linked 第一步:sudo chown -R $(whoami) $(brew --prefix)/* 第二步:br ...
- 【网易官方】极客战记(codecombat)攻略-地牢-轰轰
关卡连接: https://codecombat.163.com/play/level/pong-pong 挑战:使用迄今为止学到的所有编程技巧编写最短的解决方案! 简介: 单挑,这是特殊的挑战关卡! ...
- Git的基本使用 -- 创建本地仓库
下载安装 Git-2.25.0-64-bit .exe 查看是否安装成功 git --version 创建本地仓库 创建一个文件夹用于存放项目文件 在创建好的文件中右键选择 Git Bash Here ...
- Hadoop服务的端口50070无法访问的问题
Hadoop启动之后,遇到一个奇怪的问题: VMware虚拟机中Hadoop服务的端口50070无法访问的问题---通过127.0.0.1:50070.localhost:50070.主机名:5007 ...
- Educational Codeforces Round 76 (Rated for Div. 2) B. Magic Stick
Recently Petya walked in the forest and found a magic stick. Since Petya really likes numbers, the f ...