Question

Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And...

Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!!

​And also I have codes but just donot work so make sure that it works.

Requested files: CrosswordGenerator.cpp, CrosswordGenerator.h, CrosswordGenerator_test.cpp

CrosswordGenerator - Write a program that helps to generate a crossword puzzle by organizing words that share letters.  

For this assignment, you will write a program that forms the basis of a crossword puzzle generator. In order to create a crossword puzzle you need to identify letters that are common to one or more words. This program helps you generate crossword puzzles by identifying letters that are common to several words and string them in an intermediate data structure.

Using intermediate data structures is one way to simplify your coding. You create a data structure that organizes your input so the final output is easier to create. Your CrosswordGenerator program will open a file containing a list of words. To prepare for crossword puzzle generation your code should implement the following pseudo code:

  1. Open a file named wordlist.txt
  2. Determine the number of words (N) in the file.
  3. Create an array of that size called wordArray[];
  4. Read all the words from the file into an array called wordArray[N].
  5. Sort the array of words by length in descending order
  6. Start at the beginning of the array (the longest word) and examine the word
  7. Find all other words in the array that can intersect the current word
  8. Two words can intersect if they share a letter.
  9. Write a function called String sharedLetters(String S1, String S2)
  10. Implement sharedLetters(S1,S2) that will return a string containing letters shared by the two parameter strings S1 and S2.
  11. If no letters are shared between S1 and S2 sharedLetters() should return the empty string "".
  12. sharedLetters(S1,S2) should ignore case; capital and lower case letters are considered equal
  13. Create a two dimensional array of Strings wordsIntersect[N][N] where each dimension N is the size of wordArray.
  14. Iterate over wordArray comparing distinct words. Do not compare a word to itself.
  15. If wordArray[i] shares any letters with wordArray[j] place the result of sharedLetters(wordArray[i],wordArray[j]) into wordsIntersect[i][j]
  16. Non-alphabetic characters should be ignored.

  17. Upper and lower case letters should be equivalent. Your program should not treat them as distinct tokens.

  18. The order of shared letters is not a consideration for this program.

  19. Write the contents of the wordsIntersect array to a Comma Separated Values (CSV) text file named wordsIntersect.csv in row-major form: row,col,value. In the example below, there is an entry in wordsIntersect[12][33] which contains the string "tci". There would also be a line in wordsIntersect.csv that contains 12,33,tci -- there are no quotes around the letters and the line ends after the letter 'i'. Given that wordsIntersect[12][78] will contains "" there would be a line in the file containing: 12,78, where there is an end of line after the last comma.

N.B.

Example of what sharedLetters() output.

SharedLetters(transaction,dictum) returns "tci"
SharedLetters(Transaction,kudzu) returns ""

If "transaction" is stored in wordArray[12] and "dictum" is stored in wordArray[33] then wordsIntersect[12][33] will contain "tci"

if "kudzu" is stored in wordArray[78] then wordsIntersect[12][78] will contain ""

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

Hi Go through this code here i have a used a mtarrix of 5,5 jst add a code of taking input from file and count the chracters and define the size of mattix as the count

#include <iostream>

using namespace std;
using std::cout;
using std::endl;

int main()
{
int k, length, startCol, startRow, endCol, endRow; bool found;
char c[5][5] = {{'p', 'k', 'q', 'a', 'h'},
{'s', 'n', 'o', 'w', 'y'},
{'l', 'o', 'l', 'a', 'd'},
{'x', 't', 'o', 'y', 's'},
{'v', 's', 'c', 'x', 'g'}};
int n;
for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { cout << c[i][j] << " "; }
cout << endl; }
cout << "Please select a word to search for; hit 1 for 'snow', 2 for 'lola', 3 for 'away', 4 for 'toys', or 5 for 'knot': " << endl;
cin >> n;
if (n == 1)
{
char word[5] = "snow"; found = false; k = 0; length = 4;
for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (c[i][j] == word[k]) { if (k == 0) {startCol = j; startRow = i;}
else if (k == length - 1) { endCol = j; endRow = i; found = true;} k++;} else k = 0; }
if (found) { break;} }
if (found) { cout << "The word " << word << " starts at (" << startCol << ", " << startRow << ") and ends at (" <<
endCol << ", " << endRow << ")" << endl; } system ("PAUSE");
}

else if (n == 2)
{
char word[5] = "lola"; found = false; k = 0; length = 4;
for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (c[i][j] == word[k]) { if (k == 0) {startCol = j; startRow = i;}
else if (k == length - 1) { endCol = j; endRow = i; found = true;} k++;} else k = 0; }
if (found) { break;} }
if (found) { cout << "The word " << word << " starts at (" << startCol << ", " << startRow << ") and ends at (" <<
endCol << ", " << endRow << ")" << endl; } system ("PAUSE");
}

else if (n == 3)
{
char word[5] = "away"; found = false; k = 0; length = 4;
for (int j=0; j<5; j++) { for (int i=0; i<5; i++) { if (c[i][j] == word[k]) { if (k == 0) {startCol = j; startRow = i;}
else if (k == length - 1) { endCol = j; endRow = i; found = true;} k++;} else k = 0; }
if (found) { break;} }
if (found) { cout << "The word " << word << " starts at (" << startCol << ", " << startRow << ") and ends at (" <<
endCol << ", " << endRow << ")" << endl; } system ("PAUSE");
}

else if (n == 4)
{
char word[5] = "toys"; found = false; k = 0; length = 4;
for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { if (c[i][j] == word[k]) { if (k == 0) {startCol = j; startRow = i;}
else if (k == length - 1) { endCol = j; endRow = i; found = true;} k++;} else k = 0; }
if (found) { break;} }
if (found) { cout << "The word " << word << " starts at (" << startCol << ", " << startRow << ") and ends at (" <<
endCol << ", " << endRow << ")" << endl; } system ("PAUSE");
}

else if (n == 5)
{
char word[5] = "knot"; found = false; k = 0; length = 4;
for (int j=0; j<5; j++) { for (int i=0; i<5; i++) { if (c[i][j] == word[k]) { if (k == 0) {startCol = j; startRow = i;}
else if (k == length - 1) { endCol = j; endRow = i; found = true;} k++;} else k = 0; }
if (found) { break;} }
if (found) { cout << "The word " << word << " starts at (" << startCol << ", " << startRow << ") and ends at (" <<
endCol << ", " << endRow << ")" << endl; }
system ("PAUSE");
}
return 0; system ("PAUSE");
}

Add a comment
Know the answer?
Add Answer to:
Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And...
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
  • C Language program. Please follow the instructions given. Must use functions, pointers, and File I/O. Thank...

    C Language program. Please follow the instructions given. Must use functions, pointers, and File I/O. Thank you. Use the given function to create the program shown in the sample run. Your program should find the name of the file that is always given after the word filename (see the command line in the sample run), open the file and print to screen the contents. The type of info held in the file is noted by the word after the filename:...

  • Please Use C++ Language. And Note that please donot post the answer already there Because there...

    Please Use C++ Language. And Note that please donot post the answer already there Because there is similar answer code but I need with modified Quick sort algorithm ​. Update your program from ... Create an array that holds 1000 random integers between 1-1000. Allow the user to enter an integer to search. Create and implement modified Quick sort algorithm which will sort the array before the Binary Search algorithm is executed. Create and implement a Binary Search Algorithm ....

  • Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters...

    Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters student first name, 10 characters middle name, 20 characters last name, 9 characters student ID, 3 characters age, in years (3 digits) 2- Open the input file. Check for successful open. If the open failed, display an error message and return with value 1. 3- Use a pointer array to manage all the created student variables.Assume that there will not be more than 99...

  • 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...

  • The language is C++. Code needs to be added to line 28 and 37. Could someone...

    The language is C++. Code needs to be added to line 28 and 37. Could someone provide some help with how to do it? CODE Write a program to unscramble words A file with list of words is provided along with a template program to get you started. 1. Define a struct with 2 string members: sorted and original 2. Declare an array of 200000 elements with data type of the struct 3. Read from a file a list of...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • Write a C program that takes two sets of characters entered by the user and merge...

    Write a C program that takes two sets of characters entered by the user and merge them character by character. Enter the first set of characters: dfn h ate Enter the second set of characters: eedtecsl Output: defend the castle Your program should include the following function: void merge(char *s3, char *s1, char *s2); The function expects s3 to point to a string containing a string that combines s1 and s2 letter by letter. The first set might be longer...

  • Assignment 1 In this assignment you will be writing a tool to help you play the...

    Assignment 1 In this assignment you will be writing a tool to help you play the word puzzle game AlphaBear. In the game, certain letters must be used at each round or else they will turn into rocks! Therefore, we want to create a tool that you can provide with a list of letters you MUST use and a list of available letters and the program returns a list of all the words that contain required letters and only contain...

  • Hello I need a small fix in my program. I need to display the youngest student...

    Hello I need a small fix in my program. I need to display the youngest student and the average age of all of the students. It is not working Thanks. #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <algorithm> using namespace std; struct Student { string firstName; char middleName; string lastName; char collegeCode; int locCode; int seqCode; int age; }; struct sort_by_age { inline bool operator() (const Student& s1, const Student& s2) { return (s1.age < s2.age); // sort...

  • SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! myst...

    SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...

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