Create a 2d array puzzle that will find the following words


Create a 2d array puzzle that will find the following words; this, two,fat,that.

/word puzzle with 3 rows and 3 columns

#include
#include

using namespace std;

#define R 3
#define C 3

string puzzle []={};

int c = sizeof(puzzle)/sizeof(puzzle[0]);

bool isword(string & string)

{
for (inti=0; i if (string.compare(puzzle[i])== 0)
return true;
return false;
}
void findwordUtil(char puzzle[R][C], bool visited [R][C], inti, int j, string & string)

visited[i][j] = true
string = string + puzzle[i][j];

if (isWord(string))
cout<< string< for (int row=i-1; row<=i&& row for (int collate=j-1 && row if (row>=0 && collate>=0 && ! visited[row][collate])
findWordsUtil(puzzle, visited, row, collate, string);
string.erase(string.length()-1);
visited[i][j]=false;
}
void findWords(char puzzle[R][C] = {{false}};
string string = "";

for (int j=0; jfindWordsUtil(puzzle, visited, i.j. string);{{t,y,i,s}}
{{w,a,t,s}}
{{o,a,h,g}}
{{f,g,d,t}}

cout<< "words in the puzzle\n";
findWords(puzzle);
return 0;

}

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Create a 2d array puzzle that will find the following words
Reference No:- TGS01567130

Expected delivery within 24 Hours