【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1889
题意:给出一个表,每个国家的石头剪子布的叫法,给两个人用自己国家的语言进行石头剪子布,进行统计,最后输出胜负信息。
分析:就是模拟,先用map去映射每一个字符串,3种分别为1,2,3,然后进行统计判定即可,注意坑点就是输出时候有单复数区别,还有输出格式比较容易错。
代码:
/* *********************************************** Author :Torrance_ZHANG Created Time :2016/5/2 15:04:40 File Name :ceshi.cpp ************************************************ */#include<iostream> #include<stdio.h> #include<queue> #include<string.h> #include<math.h> #include<string> #include<map> using namespace std; map<string,int>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 #"<<id++<<":"<<endl;cout<<na.name<<": "<<num[1]<<" point" << (num[1]==1?"":"s")<<endl;cout<<nb.name<<": "<<num[2]<<" point"<<(num[2]==1?"":"s")<<endl;if(num[1]==num[2])cout<<"TIED GAME"<<endl;else if(num[1]>num[2]){cout<<"WINNER: "<<na.name<<endl;}else if(num[1]<num[2]){cout<<"WINNER: "<<nb.name<<endl;}cout<<endl;if(op=="."){flag=true;}break;} else{string op2;cin>>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
【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)相关推荐
- 洛谷 1563 玩具谜题——模拟水题
题目:https://www.luogu.org/problemnew/show/P1563 模拟水题. #include<iostream> #include<cstdio> ...
- 【CCCC】L2-027 名人堂与代金券 (25分),模拟水题
problem L2-027 名人堂与代金券 (25分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习"数据结构"课程的学生,想要获得一张合 ...
- 【HDU - 1326】Box of Bricks(模拟水题)
题干: Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds ...
- poj 3095 Linear Pachinko 模拟水题
题意: 给一个字符串,求小球随机放在上面进洞或到达两边之外的期望. 分析 水题,直接模拟. 代码: //poj 3095 //sep9 #include <iostream> using ...
- hdu 2025:查找最大元素(水题,顺序查找)
查找最大元素 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- BNUOJ 6038 - Reaux! Sham! Beaux!(模拟)
这是一个水模拟,但是因为图片看不清,手打比较烧脑,我们错了好多次才过 #include<stdio.h> #include<iostream> #include<stri ...
- 【HDU - 2398 】Savings Account (水题模拟)
题干: Suppose you open a savings account with a certain initial balance. You will not make any withdra ...
- 【HDU 5532 Almost Sorted Array】水题,模拟
给出一个序列(长度>=2),问去掉一个元素后是否能成为单调不降序列或单调不增序列. 对任一序列,先假设其可改造为单调不降序列,若成立则输出YES,不成立再假设其可改造为单调不增序列,若成立则输出 ...
- hdu 2275 Kiki Little Kiki 1 水题
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2275 这个题比较简单,所以就没有测试样例提供给大家,基本把题目的样例过了就可以了 题目大意 给你一串操作, ...
最新文章
- 修改echarts环形图的牵引线及文字位置
- html将边框向下移的代码,设置margin-left实现div右移
- 实现对象的复用——享元模式
- nginx 504 Gateway Time-out 解决办法
- 遗传算法python
- 基于鱼群算法的函数寻优
- 【mqtt】client测试工具使用
- 关于程序设计大赛环境部署的WBS图
- java abs是什么意思_Java abs()方法
- OOP,Object Oriented Programming 面向对象的三大特性 五大基本原则
- element ui的upload上传视频内容
- 在浏览器中打开“只能用微信内置浏览器”打开的页面
- mysql (1205, 'Lock wait timeout exceeded; try restarting transaction')
- 2020十月蓝桥杯B组省赛
- C#,.net使用特性类,将json转为实体时验证字段
- 详解MySQL之事务
- 为知笔记有linux版本吗,为知笔记Linux版
- win11小组件关闭的详细教程
- 我爱崔紫娟。——康益明.一辈子那么长,我等你。
- SharePoint 中关于event receivers的讨论