Question

C++ Programming help to write a code with the components: Randomly generate a 5x5 grid of...

C++ Programming help to write a code with the components:

Randomly generate a 5x5 grid of random letters. Create an interface to allow for the entry of a candidate word. If the word if found, the user interface will indicate this, if not, it will also inform the user. Allow for multiple words on the same grid to be guessed. Also allow for the ability to generate a new grid.

Letters are considered to be touching if they are horizontally, vertically, or diagonally adjacent. For example, the board:

Q W E R T

A S D F G

Z X C V B

Y U A O P

G H J K L

contains the words WAS, WAXY, JOB, and others, but not the word BOX. Words can contain duplicate letters, but a single letter in the gridmay not appear twice in a single word, for example POP is not contained in this grid.

Hint: Search the board for the first letter of the word entered, and then recursively search around the found letter for the remaining letters of the word.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <bits/stdc++.h>

using namespace std;

  

const int MAX = 26;

  

// Returns a string of random alphabets of

// length n.

string printRandomString(int n)

{

    char alphabet[MAX] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',

                          'h', 'i', 'j', 'k', 'l', 'm', 'n',

                          'o', 'p', 'q', 'r', 's', 't', 'u',

                          'v', 'w', 'x', 'y', 'z' };

  

    string res = "";

    for (int i = 0; i < n; i++)

        res = res + alphabet[rand() % MAX];

      

    return res;

}

  

// for finding random alphabets

int main()

{

   srand(time(NULL));

   int n = 10;

   cout << printRandomString(n);

   return 0;

}

Add a comment
Know the answer?
Add Answer to:
C++ Programming help to write a code with the components: Randomly generate a 5x5 grid of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help in c++ programming to output the lines in my code: if word if found:...

    Need help in c++ programming to output the lines in my code: if word if found:            cout << "'" << word << "' was found in the grid" << endl;            cout << "'" << word << "' was not found in the grid" << endl; The words can be touching if they are horizontally, vertically, or diagonally adjacent. For example, the board: Q W E R T A S D F G Z X C V B Y U A...

  • This is Matlab. Need answers with proper comments, please. Thanks In this part, you need to...

    This is Matlab. Need answers with proper comments, please. Thanks In this part, you need to write a simplified "Hangman" game: https:/len.wikipedia.org/wikilHangman (gamee WSA9 part5 Welcome to a simplified Hangman-style guessing g Here is a random word selected from the 100 most common nouns in the English language. For this, you will need to find and download a dictionary of the 100 most common English nouns and Pleas uess a letters Nothing guessed, exitting... > WSA9 parts store as a...

  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

  • This is for C programming: You will be given files in the following format: n word1...

    This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...

  • C programming. Write the code described in the picture with given 2 example executions of the...

    C programming. Write the code described in the picture with given 2 example executions of the code, and they must match. AND YOU CANT USE if statements! Problem: Allow the user to enter a positive integer value to represent the seed value for the random number generator. Next, generate a random integer that represents a possible number of points that a student may earn in a given class (0 to a maximum of 1000 possible points). Calculate the corresponding letter...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • C++ program: can you help create a autocorrect code using the cpp code provided and the...

    C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • Create C++ program.Convert this string to Tap Code using structures. It is very important to use structures in this program. The tap code is based on a Polybius square using a 5×5 grid of letters repr...

    Create C++ program.Convert this string to Tap Code using structures. It is very important to use structures in this program. The tap code is based on a Polybius square using a 5×5 grid of letters representing all the letters of the Latin alphabet, except for K, which is represented by C. The listener only needs to discriminate the timing of the taps to isolate letters. Each letter is communicated by tapping two numbers the first designating the row (Down) the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT