【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 ...
随机推荐
- 使用Limit实现分页
limit语法 #语法 SELECT * FROM table LIMIT stratIndex,pageSize SELECT * FROM table LIMIT 5,10; // 检索记录行 6 ...
- Elasticsearch集群知识笔记
Elasticsearch集群知识笔记 Elasticsearch内部提供了一个rest接口用于查看集群内部的健康状况: curl -XGET http://localhost:9200/_clust ...
- HTML连载61-焦点图、固定定位
一.焦点图 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- hdu2328 后缀树
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #in ...
- Flink 应用的一致性保障
应用一致性保障 在Flink中,会自动做检查点,用于故障时恢复一个应用.在恢复时,application的state信息可以根据最近完成的检查点进行重建,并继续运行.不过,仅将一个applicatio ...
- 3.创建springboot程序
有两种方式创建springboot项目 第一种方式:在官网上创建(基本上不用) Spring官方提供了非常方便的工具 Spring Initializr:https://start.spring.io ...
- AC3 bit allocation
1.bit allocation overview bit allocation通过分析audio 信号的频谱envelop,使用masking effect来确定使用多少bit来表示频率系数的man ...
- winform学习(2)窗体属性
窗体也属于控件(controls) 主窗体:在Main函数中创建的窗体,当关闭主窗体时,整个程序也就关闭了. 如何打开控件属性面板: ①在该控件上单击鼠标右键--属性. ②选中该控件,按F4 窗体常用 ...
- HTML5学习(5)实体字符
HTML Entity 实体字符通常用于在页面中显示一些特殊符号. 书写方式: 1. &单词; 2. &#数字; 常用实体字符: < < litter than &g ...
- BZOJ 2342 [Shoi2011]双倍回文(Manacher)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2342 题意:求最长子串使得它有四个相同的回文串SSSS相连组成. 首先跑一边Manach ...