当前位置:网站首页>L1-019 谁先倒 (15 分)
L1-019 谁先倒 (15 分)
2022-06-24 06:47:00 【代码骑士】
划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就输了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。
下面给出甲、乙两人的酒量(最多能喝多少杯不倒)和划拳记录,请你判断两个人谁先倒。
输入格式:
输入第一行先后给出甲、乙两人的酒量(不超过100的非负整数),以空格分隔。下一行给出一个正整数N(≤100),随后N行,每行给出一轮划拳的记录,格式为:
甲喊 甲划 乙喊 乙划
其中喊是喊出的数字,划是划出的数字,均为不超过100的正整数(两只手一起划)。
输出格式:
在第一行中输出先倒下的那个人:A代表甲,B代表乙。第二行中输出没倒的那个人喝了多少杯。题目保证有一个人倒下。注意程序处理到有人倒下就终止,后面的数据不必处理。
输入样例:
1 1
6
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
15 1 1 16
输出样例:
A
1思路:
①数据结构:结构体
②算法:比较
源代码:
#include<iostream>
using namespace std;
struct A
{
int max;
int han;
int hua;
int d;
}a;
struct B
{
int max;
int han;
int hua;
int d;
}b;
int ans_r;
char ans_c;
int key=0;//key=0,答案未出
int main()
{
cin>>a.max>>b.max;
int round;
cin>>round;
a.d=0;b.d=0;
for(int i=0;i<round;i++)
{
cin>>a.han>>a.hua>>b.han>>b.hua;
if(a.hua==b.han+a.han)
{
a.d++;
b.hua==b.han+a.han;
if(a.hua==b.hua)
a.d--;
}
if(b.hua==b.han+a.han)
{
b.d++;
a.hua==b.han+a.han;
if(a.hua==b.hua)
b.d--;
}
if(a.d>a.max&&key==0)
{
ans_c='A';
ans_r=b.d;
key=1;
}
if(b.d>b.max&&key==0)
{
ans_c='B';
ans_r=a.d;
key=1;
}
}
if(key==1)
{
cout<<ans_c<<endl<<ans_r;
}
return 0;
} 边栏推荐
- [Lua language from bronze to king] Part 2: development environment construction +3 editor usage examples
- Black box and white box models for interpretable AI
- 保留一位小数和保留两位小数
- Deploy L2TP in VPN (Part 1)
- Event related | reveal how Ti-One's support ability for large-scale events is developed
- 闲谈:3AC到底发生了什么?
- MSSQL high permission injection write horse to Chinese path
- opencvsharp二值图像反色
- Cloud development who is the source code of undercover applet
- Obtain the package name, application name, icon, etc. of the uninstalled APK through packagemanager. There is a small message
猜你喜欢
随机推荐
Opencvsharp binary image anti color
tuple(元组)备注
Jenkins 太老了 试试它?云原生 CI/CD Tekton
Q & A on cloud development cloudbase hot issues of "Huage youyue phase I"
云开发谁是卧底小程序源码
exness:鲍威尔坚持抗通胀承诺,指出衰退是可能的
Global and Chinese markets for food puffers 2022-2028: Research Report on technology, participants, trends, market size and share
力扣(LeetCode)174. 地下城游戏(2022.06.23)
UTC、GMT、CST
Shell script for MySQL real-time synchronization of binlog
调用Feign接口时指定ip
Maxcompute remote connection, uploading and downloading data files
LeetCode 515 在每个数行中找最大值[BFS 二叉树] HERODING的LeetCode之路
Unity Culling 相关技术
行内元素、块元素、行内块元素
MySQL case: analysis of full-text indexing
The startup mode of cloudbase init is \Cloudbase init has hidden dangers
UE常用控制台命令
C escape character
Hongmeng development IV









