Thank you for your reply!
So, I guess, something like this would apply for my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
vector<string> ingredients;
string ingredient;
string answer;
string yes;
yes=="yes";
cout << "Do you have any ingredient, yes or no? " << flush;
cin >> answer;
while (answer == "yes")
{
cout << "Enter ingredient: " <<flush ;
cin >> ingredient;
ingredients.push_back (ingredient);
cout << "More ingredients, yes or no? " << flush;
cin >> answer;
}
for (vector<string>::iterator i = ingredients.begin();
i != ingredients.end();
++i)
{
cout << "You have: "<<endl;
cout << *i << endl;
}
return 0;
}
|
Now I am wondering, how would I get from this code output in one sentence, like for example "You have: tomato, ham, chees." , and not what I get, new output for every element of the vector.
Next, something I still don't know, although I was trying in different ways is, how to go through my vector, and check all the elements to see if any of the elements is the same as any of the elements in pizza or pasta arrays, from the code from the first post.
And then sort them to get outputs either like:
pizza has this ingredients that you have:
pasta has this ingredients that you have:
or both of them don't have any of the ingredients you listed.
Thank you in advance!