Question: Modify the C + + and header files attached in the program and write the code for the followingfunctions:a . Move board up : move
Modify the C and header files attached in the program and write the code for the followingfunctions:a Move board up : moveupint board int numrowsb Move board down : movedownint board int numrowsc Move board left : moveleftint board int numrowsd Move board right : moverightint board int numrows
#include
#include
#include
using namespace std;
void moveleftint board int numrows
for int row ; row ; row
for int col ; col numrows ; col
if boardrowcol
boardrowcol boardrowcol ;
boardrowcol ;
void moverightint board int numrows
for int row ; row ; row
for int col numrows ; col ; col
if boardrowcol
boardrowcol boardrowcol ;
boardrowcol ;
void moveupint board int numrows
for int col ; col ; col
for int row ; row numrows ; row
if boardrowcol
boardrowcol boardrow col;
boardrow col;
void movedownint board int numrows
for int col ; col ; col
for int row numrows ; row ; row
if boardrowcol
boardrowcol boardrow col;
boardrow col;
void printboardint board int numrows
cout endl t endl;
for int r ; r numrows; r
for int c ; c ; c
ifboardrc
cout t right setw setfill boardrc;
else
cout t right setw setfill;
cout boardrctt;
cout t endl;
cout t endl;
cout t endl endl;
void insertrandomint board int numrows
int r c;
count empty
int emptycount ;
for int r ; r numrows; r
for int c ; c ; c
if boardrc
emptycount;
if emptycount
while true
generate random location r c
r rand numrows;
c rand numrows;
check if empty
if boardrc
add number randomly
boardrcrand;
break;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
