博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)
阅读量:4583 次
发布时间:2019-06-09

本文共 1688 字,大约阅读时间需要 5 分钟。

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1889

题意:给出一个表,每个国家的石头剪子布的叫法,给两个人用自己国家的语言进行石头剪子布,进行统计,最后输出胜负信息。

分析:就是模拟,先用map去映射每一个字符串,3种分别为1,2,3,然后进行统计判定即可,注意坑点就是输出时候有单复数区别,还有输出格式比较容易错。

 

代码:

/* ***********************************************Author        :Torrance_ZHANGCreated Time  :2016/5/2 15:04:40File Name     :ceshi.cpp************************************************ */#include
#include
#include
#include
#include
#include
#include
using namespace std;map
mm;struct Node{ string name; string nation; Node(string a="",string b=""):name(b),nation(a){}};void init(){ mm["Kamen"]=mm["Rock"]=mm["Pierre"]=mm["Stein"]=mm["Ko"]=mm["Koe"]=mm["Sasso"]=mm["Roccia"]=mm["Guu"]=mm["Kamien"]=mm["Piedra"]=1; mm["Nuzky"]=mm["Scissors"]=mm["Ciseaux"]=mm["Schere"]=mm["Ollo"]=mm["Olloo"]=mm["Forbice"]=mm["Choki"]=mm["Nozyce"]=mm["Tijera"]=2; mm["Papir"]=mm["Paper"]=mm["Feuille"]=mm["Papier"]=mm["Papir"]=mm["Carta"]=mm["Rete"]=mm["Paa"]=mm["Papier"]=mm["Papel"]=3;}int main(){ string a,b; init(); int id=1; bool flag=false; while(cin>>a>>b){ Node na(a,b); cin>>a>>b; Node nb(a,b); string op; int num[5]={ 0}; while(cin>>op){ if(!flag){ if(op=="-"||op=="."){ cout<<"Game #"<
<<":"<
num[2]){ cout<<"WINNER: "<
<
>op2; if(mm[op]!=mm[op2]){ if(mm[op]==1&&mm[op2]==2){ num[1]++; } else if(mm[op]==1&&mm[op2]==3){ num[2]++; } else if(mm[op]==2&&mm[op2]==1){ num[2]++; } else if(mm[op]==2&&mm[op2]==3){ num[1]++; } else if(mm[op]==3&&mm[op2]==1){ num[1]++; } else if(mm[op]==3&&mm[op2]==2){ num[2]++; } } } } } if(flag) return 0; }}

 

转载于:https://www.cnblogs.com/Torrance/p/5452419.html

你可能感兴趣的文章
纪中2016.10.29比赛总结
查看>>
jzoj100048. 紧急撤离
查看>>
令人疑惑的 std::remove 算法
查看>>
Int..的范围
查看>>
HDU 2585 [Hotel]字符串递归处理
查看>>
ffmpeg 编码h264 profile如何设置为baseline的问题
查看>>
CSharper 学Quick-Cocos2d-X (一) 开发环境的搭建
查看>>
PoolThreadCache
查看>>
使grub4dos引导启动linux
查看>>
P2597 [ZJOI2012]灾难
查看>>
LeetCode--LinkedList--206. Reverse Linked List(Easy)
查看>>
最短路径
查看>>
Console-算法[for,if]-一水仙花数(Water flower)
查看>>
IntelliJ-IDEA和Git、GitHub、Gitlab的使用
查看>>
Request——Node世界中被依赖最多的库No.2
查看>>
【共读Primer】26.[4.6]成员访问运算符 Page133
查看>>
8、OpenCV Python 图像直方图
查看>>
判断远程主机是否存在某个文件
查看>>
[SDOI2011]工作安排
查看>>
block change tracking buffer space
查看>>