题目:http://acm.hdu.edu.cn/showproblem.php?pid=6213
题意:一个人的妻子比她的丈夫大,现给出他们的生肖,问他们的年龄至少相差多少。
分析:签到题,用map。
代码:
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string,int> mp;
int main(){
mp["rat"]=1;
mp["ox"]=2;
mp["tiger"]=3;
mp["rabbit"]=4;
mp["dragon"]=5;
mp["snake"]=6;
mp["horse"]=7;
mp["sheep"]=8;
mp["monkey"]=9;
mp["rooster"]=10;
mp["dog"]=11;
mp["pig"]=12;
int t;cin>>t;
string a,b;
while(t--){
cin>>a>>b;
if(a==b) cout<<12<<endl;
else cout<<(mp[b]-mp[a]+12)%12<<endl;
}
}