The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a C++ program that, given a seven-digit number, writes to a file every possible seven-letter word corresponding to that number. There are 2187 (3 to the seventh power) such words.
Include the numbers 0 and 1; just embed them in the words as a 0 and a 1. Example: one possibility for 5701679 would be: LR01OPW. Assume the user correctly enters only 7 digits (no A????1-A????1). Read the user input into a char array. Use a recursive function to build the combinations. Leave the output in a file and inform the user of the file name before exiting.
You will need some constants:
const int ROWSIZE = 10;
const int COLSIZE = 5;
const int NUMSIZE = 8;
You will need an array to read in the userA????1s 7-digit number, a 2-dimensional character array, and an array in which to build the number combinations:
char array[NUMSIZE]; // user input A????1 do not go beyond 7 chars and a null byte!
// 2-d array of letters
char letters[ROWSIZE][COLSIZE] = { { '0', '\0', '\0', '\0', '\0' },
{ '1', '\0', '\0', '\0', '\0' },
{ 'A', 'B', 'C', '\0', '\0' },
{ 'D', 'E', 'F', '\0', '\0' },
{ 'G', 'H', 'I', '\0', '\0' },
{ 'J', 'K', 'L', '\0', '\0' },
{ 'M', 'N', 'O', '\0', '\0' },
{ 'P', 'Q', 'R', 'S', '\0' },
{ 'T', 'U', 'V', '\0', '\0' },
{ 'W', 'X', 'Y', 'Z', '\0' } };
char buildArr[ROWSIZE]; // output
Your recursive routine should have five parameters:
void combine (char *, // user input array
                            char [ROWSIZE][COLSIZE], // 2-d array of letters
                            char *, // array in which to build the output
                            int, // index into output array
                            ofstream&); // reference to the open output file
Please add comments to each line of code!
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll