Question
Please use the following code to write the program!!! #include #include using namespace std; // Function prototypes bool stringStatus(long long network, int pos); void displayNetwork(long
Please use the following code to write the program!!!
#include
#include
using namespace std;
// Function prototypes
bool stringStatus(long long network, int pos);
void displayNetwork(long long network);
int playerScore(long long network, int p);
void updateNetwork(long long &network, int pos, int p);
/* Returns true if position pos of the game network still has a string; returns
false otherwise */
bool stringStatus(long long network, int pos) {
network /= 100;
for (int i = 0; i
network /= 10;
return (network % 10 != 0);
}
/* Prints the network to the screen */
void displayNetwork(long long network) {
int p1, p2;
string s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
p1 = network / 10 % 10; // Player 1 score
p2 = network % 10; // Player 2 score
s1 = stringStatus(network, 1) ? "|" : " ";
s2 = stringStatus(network, 2) ? "|" : " ";
s3 = stringStatus(network, 3) ? "--" : " ";
s4 = stringStatus(network, 4) ? "--" : " ";
s5 = stringStatus(network, 5) ? "--" : " ";
s6 = stringStatus(network, 6) ? "|" : " ";
s7 = stringStatus(network, 7) ? "|" : " ";
s8 = stringStatus(network, 8) ? "--" : " ";
s9 = stringStatus(network, 9) ? "--" : " ";
s10 = stringStatus(network, 10) ? "--" : " ";
s11 = stringStatus(network, 11) ? "|" : " ";
s12 = stringStatus(network, 12) ? "|" : " ";
cout
cout
cout
cout
cout
cout
cout
}
/* Returns the score of Player p in network */
int playerScore(long long network, int p) {
int s = 0;
// TO DO
return s;
}
/* Performs the task of Player p cutting a string in position pos of network.
The reference parameter network should get updated, and if any coins are
disconnected, the score of Player p should be incremented, to reflect the
new network configuration */
void updateNetwork(long long &network, int pos, int p) {
// TO DO
}
int main() {
// TO DO
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started