HDU-2017 ACM/ICPC Asia Regional Qingdao Online-1008-Chinese Zodiac

2018-01-09 11:02:25 浏览数 (1)

ACM模版

描述

题解

string mapstring map 搞搞就行了,签到题。

代码

代码语言:javascript复制
#include <iostream>
#include <map>
#include <string>
#include <cmath>

using namespace std;

string s1, s2;
map<string, int> msi;

int main()
{
    msi["rat"] = 1;
    msi["ox"] = 2;
    msi["tiger"] = 3;
    msi["rabbit"] = 4;
    msi["dragon"] = 5;
    msi["snake"] = 6;
    msi["horse"] = 7;
    msi["sheep"] = 8;
    msi["monkey"] = 9;
    msi["rooster"] = 10;
    msi["dog"] = 11;
    msi["pig"] = 12;

    int T;
    scanf("%d", &T);

    while (T--)
    {
        cin >> s1 >> s2;
        if (s1 == s2)
        {
            puts("12");
        }
        else if (msi[s1] < msi[s2])
        {
            printf("%dn", abs(msi[s1] - msi[s2]));
        }
        else
        {
            printf("%dn", msi[s2] - msi[s1]   12);
        }
    }

    return 0;
}

0 人点赞