题意:

输入一个正整数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. socket 简单实现HTTP服务器

    # -*- coding: utf-8 -*- # @Time : 2019-07-17 1:39 # @File : 网络socket实现http服务器.py # @Software: PyChar ...

  2. php 基础系列之 php快速入门

    ·插补操作 将简单变量写入一个由双引号引用的字符串中,就叫插补操作.例如: $test = 'xx'; echo "你好:$test"; 注意:插补操作只是双引号引用字符串的特性. ...

  3. laravel路由组中namespace的的用法详解

    做公司一个项目的时候发现laravel框架中可以省去action的路径前缀的用法: ps:用简短的话来理解就是说在路由组中定义namespace,可以省去你路由的前缀下面看例子 最终显示如下: 定义的 ...

  4. MySQL加号+ 的作用

    案例:查询员工名和员工姓,连接成一个字段,并显示为: 姓名 SELECT last_name+first_name AS 姓名 FROM employees;没有报错但姓名一下全是0 Java中的 + ...

  5. AcWing 104. 货仓选址

    #include <iostream> #include <algorithm> using namespace std; ; int n; int q[N]; int mai ...

  6. 路飞-后台home模块

    home模块 创建home模块 """ 前提:在 luffy 虚拟环境下 1.终端从项目根目录进入apps目录 >: cd luffyapi & cd ap ...

  7. linux下grep分析apache日志的命令集合

    https://my.oschina.net/hmc0316/blog/112004 实例:月份英文简写英文全称一月Jan.January二月Feb.February三月Mar.March四月Apr. ...

  8. python 更换数据源

    1.Win+R打开cmd输入%HOMEPATH%打开自己的HOMEPATH路径文件夹 2.在此路径下建立一个文件夹pip, 里边放一个文件pip.ini内容如下: [global] timeout = ...

  9. C语言使用信号量机制实例:

    C语言使用信号量机制实例: #include <signal.h> #include <unistd.h> #include <stdio.h> #include ...

  10. Linux上查看当前系统各内存分区信息

    命令 ulimit -a -a 查看所有信息,同理,也可以例如 ulimit -s 只查看栈占内存信息