question archive I need help with de bugging my problem, and understanding where I went wrong

I need help with de bugging my problem, and understanding where I went wrong

Subject:Computer SciencePrice: Bought3

I need help with de bugging my problem, and understanding where I went wrong. Please help me see where my problem is. I had a hard time reading and understanding it.

Problem:

8.15 LAB: Replacement words

a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced.

Ex: If the input is:

3  automobile car  manufacturer maker  children kids

15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one.

then the output is:

The car maker recommends car seats for kids if the car doesn't already have one.

You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one.

Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements.

Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function returns -1.

int FindWordInWordList(vector<string> wordList, string wordToFind)

 

Code:

#include <iostream>

#include <vector>

using namespace std;

bool wordList(vector<int> myVec)

{

 for (int i = 0; i < myVec.size(); ++i)

 {

  if (myVec[i] % 2 == 1)

  {

    return false;

  }

 }

 return true;

}

bool wordList (vector<int> myVec)

{

 for (int i = 0; i < myVec.size(); ++i)

 {

  if (myVec[i] % 2 == 0)

  {

    return false;

  }

 }

 return true;

}

int main()

{

 vector<int> vec;

 int n, num,i;

 cin >> n;

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

 {

  cin >> num;

  vec.push_back(num);

 }

 if (wordlist (vec))

 {

  cout << "Find word list" << endl;

 }

 

 return 0;

}

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE