Chinese Zodiac (水题)
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be 22 years. But if the signs of the couple is the same, the answer should be 1212 years.
Input
The first line of input contains an integer T (1≤T≤1000)T (1≤T≤1000) indicating the number of test cases.
For each test case a line of two strings describes the signs of Victoria and her husband.
Output
For each test case output an integer in a line.
Sample Input
3
ox rooster
rooster ox
dragon dragon
Sample Output
8
4
12
题解:感觉用map更好,但是我STL玩的还是不是特别好,就用二维字符数组代替了
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
char a[12][15]={"rat","ox","tiger","rabbit","dragon","snake","horse","sheep","monkey","rooster","dog","pig"};
int n;
cin>>n;
char s1[15],s2[15];
int k1,k2;
for(int t=0;t<n;t++)
{
scanf("%s%s",s1,s2);
for(int j=0;j<12;j++)
{
if(strcmp(s1,a[j])==0)
{
k1=j;
}
if(strcmp(s2,a[j])==0)
{
k2=j;
}
}
if(k1==k2)
{
printf("12\n");
}
if(k1<k2)
{
printf("%d\n",k2-k1);
}
if(k1>k2)
{
printf("%d\n",12+k2-k1);
}
}
return 0;
}
Chinese Zodiac (水题)的更多相关文章
- HDU 6213 Chinese Zodiac 【模拟/水题/生肖】
Problem Description The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each y ...
- 2017 ACM/ICPC Asia Regional Qingdao Online - 1008 Chinese Zodiac
2017-09-17 13:28:04 writer:pprp 签到题:1008 Chinese Zodiac #include <iostream> #include <strin ...
- 2017青岛网络赛1008 Chinese Zodiac
Chinese Zodiac Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) T ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
随机推荐
- BZOJ4545: DQS的trie
BZOJ4545: DQS的trie https://lydsy.com/JudgeOnline/problem.php?id=4545 分析: 对trie用dfs建sam复杂度是\(O(n^2)\) ...
- easy_install下载地址及安装
下载地址 https://pypi.python.org/pypi/setuptools 解压 tar -xzvf xx.tar.gz 安装 cd 解压目录 sudo python setup.py ...
- POJ百练—IP地址转换
#include<iostream> #include<cstdio> #include<cstring> using namespace std; ]; void ...
- Webpack 基础使用
使用webstorm编译: 1.新建一个工程(最基本的工程) 2.在webstorm的控制台,使用命令行 cnpm install webpack -g 全局安装 3.安装完后,可以使用 ...
- etcd命令
etcdctl支持下面列出来的命令,基本上可以分为数据库操作和非数据库操作,可以查看etcdctl README.md来了解更多 ➜ ~ etcdctl -hNAME: etcdctl - A sim ...
- shell入门-grep过滤-1
正则表达式,就是一个字符串.有一定的规律.我们用指定的字符串匹配一个指定的行.指定的字符串就是正则表达式. 正则表达式有这几个工具:grep egrep sed awk 命令:gerep 说明:过滤出 ...
- 如何在niosII中添加i2c外设_winday_新浪博客
如何在niosII中添加i2c外设_winday_新浪博客 如何在niosII中添加i2c外设 winday 摘要:本文说明了如何在niosII添加第三方i2c外设,以供参考. 由于本人使用的Alte ...
- SpringMVC 学习笔记(文件的上传和下载)
在web项目中会遇到的问题:文件上传 文件上传在前端页面的设置:form表单 设置 input 类型 文件上传的请求方式要使用post,要将enctype设置为multipart/form-data ...
- 每天一道算法题(1) ——不用乘除法求和1+2+…+n
题目:求1+2+-+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字以及条件判断语句(A?B:C). 方法1:使用函数指针. typedef int (*fu ...
- linux-java环境安装以及ssh
1 下载Java8 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 2 使用 ...