86.9k views
5 votes
Given code

#include
#include
using namespace std;
bool weHaveWinner(int a,int b)
{
return (a>=21 && b>=21 && abs(a-b)>1);
}
int main()
{
int aPoints = 0;
int bPoints = 0;
string input;

// ToDo: Write a loop until input is "end" or we have a winner
// the loop should read the input and add a point to aPoints if "A"
// or add a point to bPoints if "B", don't do anything but leave the
// loop if "end"

while(1)
{
cin >> input;
if(input=="end")
break;
if(input=="A")
aPoints++;
if(input=="B")
bPoints++;
if(weHaveWinner(aPoints,bPoints))
break;
}
// Tell the user if we have a winner or not
if(aPoints > bPoints + 1 && aPoints >= 21)
{
cout aPoints + 1 && bPoints >= 21)
{
cout << "Team B won! (" << aPoints << "-" << bPoints << ")" << endl;
}
else
{
cout << "Game ended as a draw. (" << aPoints << "-" << bPoints << ")" << endl;
}
return 0;
}

Given code #include #include using namespace std; bool weHaveWinner(int a,int b) { return-example-1

2 Answers

7 votes

Answer:

yeet

Step-by-step explanation:

yeet

User Or Gal
by
3.9k points
1 vote

Answer:

YES

Step-by-step explanation:

User M Polak
by
4.7k points