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 ...
随机推荐
- POJ2442:Sequence
浅谈堆:https://www.cnblogs.com/AKMer/p/10284629.html 题目传送门:http://poj.org/problem?id=2442 我们先简化题意,假设只有两 ...
- POJ2069:Super Star
我对模拟退火的理解:https://www.cnblogs.com/AKMer/p/9580982.html 我对爬山的理解:https://www.cnblogs.com/AKMer/p/95552 ...
- SQL SERVER 中的*=和=*
一.* =和= * 是在sql server2000中左连接,右连接的用法相当于left join 和right join,现在sql2005和2008默认是不支持的,可以设置兼容2000或2008 ...
- smbpasswd和pdbedit
samba用户管理: smbpasswd :smbpasswd命令属于samba套件,能够实现添加或删除samba用户和为用户修改密码. smbpasswd [options] USERNAME -a ...
- CSS多列布局Multi-column、伸缩布局Flexbox、网格布局Grid详解
新css属性为我们提供了更加便捷的网页布局方式.来自微软的thomas lewis将带你认识去Grid Alignment,Flexibox Box以及Multi-column Layout这三大领域 ...
- R语言对矩阵按某一列排序
[plain] view plaincopy a <- c(5,4,3,2,1) b <- c(1,2,3,4,5) c <- cbind(a,b) [plain] view pla ...
- 《精通Spring4.X企业应用开发实战》读后感第五章(基于注解的配置)
- Git for Windows,TortoiseGit支持WinXP的最后版本及下载方法
TortoiseGit兼容Windows XP和Windows Server 2003的最后版本: TortoiseGit 1.8.16.0 (https://download.tortoisegit ...
- ubuntu 下minicom超级终端的使用方法
http://blog.chinaunix.net/uid-25909619-id-3184639.html Ubuntu下使用sshfs挂载远程目录到本地 http://blog.csdn.net/ ...
- 1. xss原理分析与剖析(1)
0×01 前言: <xss攻击手法>一开始在互联网上资料并不多(都是现成的代码,没有从基础的开始),直到刺的<白帽子讲WEB安全>和cn4rry的<XSS跨站脚本攻击剖析 ...