GOLF CROQUET

题目描述

In golf croquet doubles, two teams of 2 play each other. Each player has their own ball which they hit when it is their turn. A turn comprises one hit of the ball.
There are 6 hoops which are each played twice, once in each direction, in a prescribed order.
A point is scored by the first team to “make” the current hoop. To make a hoop, one of the team’s balls must be knocked through the current hoop in the right direction. The first team to score 7 points wins. If the game reaches 6-6, a final deciding hoop is played. Note that a team cannot score more than 7 points – the game ends as soon as the 7 th hoop is won.
The balls are played in a fixed order: blue, red, black (blue’s partner) then yellow (red’s partner). We can record the progress of a match by recording the outcome of each shot. The code we are using is:
S a standard shot that does not make a hoop H a shot that makes a hoop for the team who played the shot D a shot that makes 2 hoops for the team who played the shot – an extremely unlikely scenario but it can happen! A team on 6 points will only score the first of the two hoops, of course.
O a shot that makes a hoop for an opponent’s ball!
The last one is almost certainly an accident, but it happens far more times than players like!

输入
The input represents part or all of a single game of golf croquet. The first two lines each contain the name of a team, each consisting of one or more words. The name will be no more than 30 characters long. The first named team play blue and black. The third line is a single integer, S, which tells how many strokes are recorded, for a game that has started but which may not yet be completed. (0 < S <= 255)

The fourth line contains S upper case letter characters, each being one of the 4 characters defined above (S, H, D or O). Blue always plays the first shot followed in turn by red, black and yellow.

输出
Output a single line of text with the current score in the form
team1name x team2name y.
Follow this by a space then one of:
teamname has won.
teamname is winning.
All square.

样例输入

Team Sally
The dragons
26
SSSSHSSSSSHSSSSSHSSSSSSHSS
样例输出
Team Sally 3 The dragons 1. Team Sally is winning.

这个题题面乱七八糟的,其实就是两个队伍,上4个队员,蓝、红、黑、黄,蓝和黑一队红和黄一队,一次打球,S是不中,H中了加一分,D中了加两分,O给对面加一分,按照这个顺序打,颜色啥用没有,但是读者不了解高尔夫规则,看了半天才发现没用。

题目简化为:
两个队伍打比赛,队伍1先打队伍2后打,存在4种情况,S不加分,H加一分,D加两分,O给对手加一分,分数不能高过7(如果已经6分,出现了D,那么也只加一分),给你两个队,给你一个数字表示过了多少回合。

  • 如果有队伍到7分,那么游戏结束
  • 在输出时,先输出两个队伍的分数
    1.如果有队伍到了7分,那么输出该队伍赢了
    2.如果没有队伍到达7分,那么输出分数高的队伍现在是赢的(is winning进行时)
    3.如果平手,输出平手

这真的真的是个S13题,我们做的时候因为题面搞了好久,C

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
string a,b;
int n;
string s;
int main()
{getline(cin,a);getline(cin,b);cin>>n;cin>>s;int ans1=0,ans2=0;int len = s.length();//突然发现N都给了还求个锤子的LEN,我佛了char ch;for(int i=0;i<len;i++){ch=s[i];if(i%2==0){if(ch=='S')continue;else if(ch=='H')ans1++;else if(ch=='D')ans1=ans1+2;else ans2++;}else{if(ch=='S')continue;else if(ch=='H')ans2++;else if(ch=='D')ans2=ans2+2;else ans1++;}if(ans1>=7||ans2>=7){break;}}if (ans1 > 7) ans1 = 7;if (ans2 > 7) ans2 = 7;cout<<a<<" "<<ans1<<" "<<b<<" "<<ans2<<". ";if(ans1==ans2) cout<<"All square."<<endl;else{if(ans1>ans2)cout<<a;else cout<<b;if(ans1==7||ans2==7)cout<<" has won."<<endl;else cout<<" is winning."<<endl;}return 0;
}

GOLF CROQUET(S13题)相关推荐

  1. 《C++ Primer Plus(第六版)》(17)(第十章 对象和类 编程题答案)

    10.10编程题 1. Test.h #ifndef _Test_H_ #define _Test_H_ #include <iostream> #include <string&g ...

  2. 蓝桥杯java第五届决赛第二题--六角幻方

    标题:六角幻方把 1 2 3 ... 19 共19个整数排列成六角形状,如下:* * ** * * ** * * * ** * * * * * *要求每个直线上的数字之和必须相等.共有15条直线哦!再 ...

  3. 高考数学考用计算机求函数吗,高考数学52种快速做题方法整理!再也不用担心考试时间不够了...

    原标题:高考数学52种快速做题方法整理!再也不用担心考试时间不够了 1 . 适用条件 [直线过焦点],必有ecosA=(x-1)/(x+1),其中A为直线与焦点所在轴夹角,是锐角.x为分离比,必须大于 ...

  4. C++ Primer Plus 第九章编程题练习

    C++ Primer Plus 第九章编程题练习 第一题 题目描述 下面是一个头文件: const int Len = 40;struct golf {char fullname[Len];int h ...

  5. leetcode刷题规划

    LeetCode精华题目列表[刷题规划系列] – TuringPlanet 目录 算法题到底在考察什么? 题目列表 Array String Linked List Queue Stack Advan ...

  6. 02-07GRE真题及答案解析整理

    [02-07年GRE真题及答案解析整理] 2002年11月23日GRE笔考题 VERBAL部分 Section 1 填空 1. Although she gives badly _______ tit ...

  7. 2022年长三角地区数学建模B题:齿轮箱故障诊断

    表单 gearbox00 为齿轮箱正常工况下采集到的振动信号;表单 gearbox10 为故障状态 1 下采集到的振动信号;表单 gearbox20 为故障状态 2 下采集到的故障信号;表单 gear ...

  8. 计算机操作系统第四版复习+部分课后题+习题

    第一章 判断操作系统类型 操作系统按功能可以分为 批处理操作系统 将选中的若干作业调入内存以多道方式投入运行. 优点是系统吞吐量大,资源利用率高. 不具有交互性,这是其缺点. 分时操作系统 ----- ...

  9. PMP 模拟200题

    PMP 模拟题三(答案和解析在最下方) 1:一项目经理正在管理他第二个项目,第二个项目在第一个项目开始一个月后启动,两个项目同时进行中.尽管第一 个项目很小,但规模与 日俱增.每经历一天,项目经理就越 ...

最新文章

  1. 程序员门槛再被“神器”降低:只要会英文,就能写代码!
  2. 【c语言】hello
  3. 浅谈NLP中的对抗训练方式
  4. html代码测试1006无标题,无标题Html5页面测试点总结文章
  5. 跟着别人的感觉做网络推广之二
  6. 使用ANTLR和Java创建外部DSL
  7. 信息学奥赛一本通 2005:【20CSPJ普及组】直播获奖 | 洛谷 P7072 [CSP-J2020] 直播获奖
  8. Atcoder Grand Contest 026 (AGC026) F - Manju Game 博弈,动态规划
  9. 如何基于Jupyter notebook搭建Spark集群开发环境
  10. 第三章·MySQL版本区别及管理
  11. Flutter进阶—质感设计之弹出菜单
  12. poi mysql 导出 excel乱码,本地tomcat正常,但liunx poi excel下载却内容乱码问题的解决方法-学派吧...
  13. Spring动态代理实现
  14. java 数字转中文_使用Java将阿拉伯数字转换为中文数字(适配小数转换)
  15. 试着在unity实现阴阳师抽卡效果
  16. 编译原理(3):词法分析
  17. 【机器学习算法】感知机模型
  18. 软件测试基础篇(1)
  19. cad快速选择命令快捷键_学好CAD必须掌握的20个常用快捷键命令
  20. 又涨了!2021 年 5 月程序员工资统计新鲜出炉,网友:还是Java程序员牛逼~

热门文章

  1. php 定時自動執行,php定时自动运行thinkphp方法(含停止)
  2. 防火墙GRE和NAT
  3. slam过去与未来1_what_salm
  4. 赵子琪 swf 动画
  5. Windows系统查看CUDA版本号
  6. 区块链与物联网的结合应用
  7. php修改树莓派wifi密码,树莓派连接WIFI无线网络配置
  8. C++实现字节数组与16进制字符串互转,字符串转16进制字符串
  9. voip技术 G7.11
  10. 盘点一下互联网最值得加入的173家国企