#Include #Include #Include #Include #Include #Include #Include Using Namespace Const
#Include #Include #Include #Include #Include #Include #Include Using Namespace Const
#include <map>
#include <set>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cstdlib>
return rev;
}
void random_letter(char(&arrays)[a][b]) {
void getwords ( const char(&arr)[a][b], map<string, int>& words, const set <string>& dict
)
{
words.clear();
//Do rows
for (size_t sr = 0; sr < a; ++sr)
if ( word.size() > 2 ) {
if (dict.count(word))
words[word]++;
words[rv]++;
}
}
//Do cols
for (size_t sc = 0; sc < b; ++sc)
if (word.size() > 2) {
if (dict.count(word))
words[word]++;
if (dict.count(rv = reverse(word)))
words[rv]++;
}
}
}
if ( !dicts.is_open() )
return false;
string read;
dicset.insert (read);
return true;
}
int main()
{
set <string> dictset;
int choice;
do {
choice = 0;
cin >> choice;
if (!cin) {
cin.clear();
cin.ignore(1000, '\n');
}
switch (choice) {
case 1: {
char arr[5][5];
random_letter(arr);
display_array(arr);
getwords(arr, words, dictset);
break;
}
case 2: {
char arr[10][10];
random_letter(arr);
display_array(arr);
getwords(arr, words, dictset);
break;
}
case 3: {
char arr[15][15];
random_letter(arr);
display_array(arr);
getwords(arr, words, dictset);
break;
}
case 4:
break;
default:
cout << "\nInvalid input!\n" << endl;
}
if (words.size()) {
cout << word.first << " " << word.second << endl;
}
else
cout << "\nNo words were found." << endl;
}