おみやげをまらいました(map)
作者:互联网
蛙蛙还是给你带来了礼物。但它有个小小的要求,那就是你得在石头剪刀布上赢过它才能拿到礼物哦!
现在根据你的观察,你已经知道了蛙蛙心想的出拳顺序,你需要安排自己的出拳顺序,使得你能在每一局中都获胜。
输入描述:
输出描述:
输入
stone sci
sci paper
paper stone
4
stone
sci
spock
paper
输出
paper
stone
Fake
sci
代码:
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<string ,string>f;
map<string , int>book;
int main()
{
for(int i = 1 ; i <= 3 ; i++)
{
string s1 , s2;
cin>>s1>>s2;
f[s2] = s1;
book[s2] = 1;
book[s1] = 1;
}
int n;
cin>>n;
for(int i = 1 ; i <= n ; i++)
{
string s;
cin>>s;
if(book[s] == 1)
cout<<f[s]<<endl;
else
cout<<"Fake"<<endl;
}
}
标签:map,stone,sci,int,s2,s1,include 来源: https://blog.csdn.net/runingyoung/article/details/116354927