Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #include using namespace std; void printit ( int data [ 5 ] [ 5 ] ) { for ( int i =
#include
#include
#include
#include
using namespace std;
void printitint data
for int i ; i ; i
for int j ; j ; j
cout dataij;
cout endl;
cout endl;
void clearint data
for int i ; i ; i
for int j ; j ; j
dataij;
int main
string sentence;
string firstword;
int x;
int row, col;
int args;
int arr;
cout u # will move the one up # times" endl;
cout d # will move the one down # times" endl;
cout l # will move the one left # times" endl;
cout r # will move the one right # times" endl;
cout "exit will leave" endl endl;
cleararr;
arr;
printitarr;
row ;
col ;
while true
cout "enter your command;
getlinecin sentence;
args sscanfssentencecstrs d firstword.cstrunsignedfirstwordlength &x;
if firstword "exit"
cout "goodbye" endl;
break;
else if firstword u firstword d firstword l firstword r
if args x ;
cout "row is row col is col endl;
for int i ; i x; i
if firstword u
row row ; Ensure it wraps around if it goes negative
else if firstword d
row row ;
else if firstword l
col col ; Ensure it wraps around if it goes negative
else if firstword r
col col ; Ensure it wraps around if it goes beyond the last column
cleararr;
arrrowcol;
printitarr;
else
cout "don't understand that" endl;
return ;
Help fix my code please I want my output to be able to Do a
l goes left and prints the matrix a total of three times notice how it should wrap around to the right
Then do a
u goes up and prints the matrix a total of two times
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