当前位置:网站首页>PAT B1071
PAT B1071
2022-06-25 19:55:00 【Madness makes freedom】
1071 Small gambling (15 branch )
As the saying goes “ Small gambling ”. This is a very simple game : First, the computer gives the first integer ; Then the player bets whether the second integer will be larger or smaller than the first one ; Players bet t After a chip , The computer gives the second number . If the player guesses right , The system rewards players t A chip ; Otherwise, deduct the player t A chip .
Be careful : Players can't bet more chips than they have in their account . When the player loses all his chips , The game is over .
Input format :
Enter... On the first line 2 A positive integer T and K(≤ 100), They are the number of chips given to players by the system in the initial state 、 And the number of games to process . And then K That's ok , Each line corresponds to a game , The order is given 4 A digital :
n1 b t n2
among n1 and n2 It is the two given by the computer [0, 9] The whole number inside , Make sure the two numbers are not equal .b by 0 Indicates that players bet Small , by 1 Indicates that players bet Big .t Indicates the number of chips the player has bet , Ensure that within the integer range .
Output format :
For every game , Output according to the following conditions ( among t It's the player's bet ,x Is the amount of chips the player currently holds ):
- Game player wins , Output
Win t! Total = x.; - Player loses , Output
Lose t. Total = x.; - Players bet more than they hold , Output
Not enough tokens. Total = x.; - After the player loses all , Output
Game Over.And end the program .
sample input 1:
100 4
8 0 100 2
3 1 50 1
5 1 200 6
7 0 200 8
sample output 1:
Win 100! Total = 200.
Lose 50. Total = 150.
Not enough tokens. Total = 150.
Not enough tokens. Total = 150.
sample input 2:
100 4
8 0 100 2
3 1 200 1
5 1 200 6
7 0 200 8
sample output 2:
Win 100! Total = 200.
Lose 200. Total = 0.
Game Over.This question really makes me a little sick !!!
Output format here each period or exclamation point ends with a space ; However, the output sample is two spaces . The final result of submitting the code is malformed , Then I stared and looked around to find the blank space. There was a problem here .emm, The subject needs further improvement !
Output format :
For every game , Output according to the following conditions ( among
tIt's the player's bet ,xIs the amount of chips the player currently holds ):
- Game player wins , Output
Win t! Total = x.;- Player loses , Output
Lose t. Total = x.;- Players bet more than they hold , Output
Not enough tokens. Total = x.;- After the player loses all , Output
Game Over.And end the program .
sample output 1:
Win 100! Total = 200.
Lose 50. Total = 150.
Not enough tokens. Total = 150.
Not enough tokens. Total = 150.
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int total,k;
cin >> total >> k;
while(k--)
{
int n1,n2,bet,bet_sum;
cin >> n1 >> bet >> bet_sum >> n2;
if(total==0)
{
printf("Game Over.\n");
break;
}
if(total<bet_sum)
{
printf("Not enough tokens. Total = %d.\n",total);
continue;
}
if((n2>n1)==bet)
{
total+=bet_sum;
printf("Win %d! Total = %d.\n",bet_sum,total);
}
else
{
total-=bet_sum;
printf("Lose %d. Total = %d.\n",bet_sum,total);
}
}
return 0;
}
边栏推荐
- Two types of attribute injection methods
- The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds
- Applet canvas generate sharing Poster
- QQ robot: self forbidden words management of group members [latest beta2 version]
- On Oracle full stack virtual machine -- graalvm
- What are Baidu collection skills? 2022 Baidu article collection skills
- 一、HikariCP获取连接流程源码分析一
- PostgreSQL change table owner
- Native JS array some method de duplication
- Why are life science enterprises on the cloud in succession?
猜你喜欢

Determine whether it is a web page opened on wechat

Ali vision AI training camp-day01

Automatic fitting when the applet reaches the top

Embark on a new journey and reach the world with wisdom

What are Baidu collection skills? 2022 Baidu article collection skills

Vulnhub range - darkhole 1

Does GoogleSEO need to change the friend chain? (e6zzseo)

Print 1 cute every 100 milliseconds ~ with a running lantern effect

Wechat applet cloud function does not have dependency option installed

JS asynchronism (I. asynchronous concept, basic use of web worker)
随机推荐
Applet canvas generate sharing Poster
QQ robot flash forwarding / recall message forwarding [latest beta2 version]
How to understand var = a = b = C = 9? How to pre parse?
Can GoogleSEO only do content without external chain? (e6zzseo)
Tcp/ip test questions (III)
Laravel validation rule followed Role of auth:: id()
Uni app through uni Navigateto failed to pass parameter (pass object)
LNMP compilation and installation
wooyun-2014-065513
Profile path and name
The meanings of /32, /48, /64 in IPv6 addresses
Apifox simple understanding -- the integrator of web side testing
打新债网上开户安全吗,需要注意什么
Lilda Bluetooth air conditioning receiver helps create a more comfortable road life
Validation of TTF font by validator of laravel
PHP little knowledge record
Genicam gentl standard ver1.5 (1)
Redis cache preheating & avalanche & breakdown & penetration
1、 Hikaricp source code analysis of connection acquisition process I
What should I pay attention to in GoogleSEO content station optimization?