测试

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
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 n;
string str1,str2;
cin>>n;
while(n–)
{
cin>>str1>>str2;
int ans=abs(12+mp[str2]-mp[str1]);
int ans1=abs(12+mp[str2]-mp[str1]);
ans=min(ans,ans1);
if(ans==0) ans=12;
if(ans>12) ans-=12;
cout<<ans<<endl;
}
return 0;
}

posted on 2019-03-12 22:15 MaxVen 阅读() 评论() 编辑 收藏

版权声明:本文为maxv原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/maxv/p/10520060.html