题目描述:
A | A#=Bb | B | C | C#=Db | D | D#=Eb | E | F | F#=Gb | G | G#=Ab |
其实就是查找上表,输入两个字符串str1和str2,如果str1在上表中有替换项,就替换成替换项输出,如果没有就输出UNIQUE.
样例输入
Ab minor
D# major
G minor 样例输出 Case 1: G# minor
Case 2: Eb major
Case 3: UNIQUE
D# major
G minor 样例输出 Case 1: G# minor
Case 2: Eb major
Case 3: UNIQUE
#include<iostream>
#include<string>
#include<map>
using namespace std;
void CreatMap(map<string,string> &mp)
{
string str1;
string str2;
str1 = "A#";
str2 = "Bb";
mp.insert(make_pair(str1,str2));
mp.insert(make_pair(str2,str1));
str1 = "C#";
str2 = "Db";
mp.insert(make_pair(str1,str2));
mp.insert(make_pair(str2,str1));
str1 = "D#";
str2 = "Eb";
mp.insert(make_pair(str1,str2));
mp.insert(make_pair(str2,str1));
str1 = "F#";
str2 = "Gb";
mp.insert(make_pair(str1,str2));
mp.insert(make_pair(str2,str1));
str1 = "G#";
str2 = "Ab";
mp.insert(make_pair(str1,str2));
mp.insert(make_pair(str2,str1));
}
int main()
{
map<string,string> mp;
map<string,string>::iterator mp_it;
string str1;
string str2;
int t = 0;
CreatMap(mp);
while(cin >> str1 >> str2)
{
mp_it = mp.find(str1);
cout << "Case " << ++t << ": ";
if(mp_it != mp.end())
cout << mp_it->second << ' ' << str2 << endl;
else
cout << "UNIQUE" << endl;
}
return 0;
}