The language is C++. Code needs to be added to line 28 and 37. Could someone pro
ID: 3575672 • Letter: T
Question
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 words into original member and the sorted version of the word into the sorted member of each element of the array 4. Continue to ask the user (interactively) to type a word or the letter q' to quit. 5. Your program will unscramble and print out all the words with the same letters as the given word. Note: this assignment only requires adding less than 20 lines of code to the template provided.Explanation / Answer
char q;
string word;
// line 26 to 29
//store words in wordlist
while(infile && i < maxSize)
{
infile >> wordlist[i];
i++;
}
numwords=i;
// line 35 to 39
do{
bool found=false;
char q;
cout<<"please type a word into unscrable or 'q' to quit:";
cin>>q;
while(word != "stop")
{
cout << "Search for: ";
cin >> word;
if(word =="stop")
{
cout << "Bye!" << endl;
break;
}
for(int k=0; k<maxSize; k++)
{
if (word == wordlist[k])
{
found = true;
j=k;
break;
}
}
j=j+1;
if (found==true)
{
cout << "'" << word << " was found in position " << a << endl;
}
else
{
cout << "Sorry, word not found." << endl;
}
}
}while(w!="q");
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.