Question: Programming Project 1 4 . 1 2 . 8 : . Repeat Programming Project 1 4 . 1 2 . 7 , but use a
Programming Project :
Repeat Programming Project but use a queue instead.
here is the work that is done but not sure where to change queue
#include
#include
#include
using namespace std;
const int MAXROWS ;
const int MAXCOLS ;
struct Pair
int row;
int col;
Pairint r int c
row r;
col c;
;
class Stack
private:
Pair dataMAXROWSMAXCOLS;
int top;
public:
Stack
top ;
void pushPair p
datatop p;
top;
bool empty
return top ;
Pair pop
return datatop;
;
bool isColoredint pixelsMAXCOLS Pair p
ifpixelsprowpcol
return true;
else
return false;
bool isValidPair p
ifprow && prow MAXROWS && pcol && pcol MAXCOLS
return true;
else
return false;
int main
Stack s;
int pixelsMAXROWSMAXCOLS;
int row, col, count ;
Pair p;
cout "Enter starting row : ;
cin row;
cout "Enter starting column : ;
cin col;
spushPairrow col;
whilesempty
p spop;
ifisColoredpixels p
pixelsprowpcol count;
count;
Pair northprow pcol;
Pair eastprow, pcol ;
Pair southprow pcol;
Pair westprow, pcol;
ifisValidnorth && isColoredpixels north
spushnorth;
ifisValideast && isColoredpixels east
spusheast;
ifisValidsouth && isColoredpixels south
spushsouth;
ifisValidwest && isColoredpixels west
spushwest;
display the pixel numbering
forint i ; i MAXROWS; i
forint j ; j MAXCOLS; j
cout setw pixelsij;
cout endl;
return ;
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
