Question
please solve it in a clear way by putting directly a screenshot of the code on VisualStudio.
you are given two lists of strings. For example list<string> Ist1 {17,14,54,56,10,11,12}; list<string> Ist2 {1
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program :

#include <iostream>

#include <string>

#include <stack>

#include <vector>

using namespace std;

int main() {

std::string common;

std::vector<std::string> vs1 = {"seventeen","fourteen","fiftyfour","fiftysix","ten","eleven","twelve"}; //vector

std::vector<std::string> vs2 = {"thirteen","nine","ten","eleven","twelve"};

std::vector<std::string> dest;

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

{

for(int j=0;j<vs2.size();j++)

{

if((vs1[i].compare(vs2[j])) == 0) //comparing vs1 and vs2

{

dest.push_back(vs1[i]); //if found pushing it to dest vector

}

}

}

if(dest.size() > 0)

common = dest[0]; //assigning dest[0] to common

std::cout<<"\n"<<common<<"\n";

}

1 i main.cpp saved #include <iostream> #include <string> #include <stack> #include <vector> using namespace std; int main()

Output:

clang version 7.0.0-3ubuntu0.18.04.1 (tags/RELEA SE_700/final) 5 clang++-7 -pthread -std=c++17 -o main main.cpp > ./main ten

Add a comment
Know the answer?
Add Answer to:
please solve it in a clear way by putting directly a screenshot of the code on...
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++ SECTION 1) (15 points) Write a full C++ program that reads an integer, a list...

    C++ SECTION 1) (15 points) Write a full C++ program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Ex: If the input is: 4 hello zoo sleep drizzle z then the output is: 200 drizzle To...

  • C++ Language: TestCase: Write a function, called "sort Lbefore e that can sort words into whether or not they conf...

    C++ Language: TestCase: Write a function, called "sort Lbefore e that can sort words into whether or not they conform to the 1 beforee, except after c rule, See htrps//en.oxtorddictionaries.com/spelling/-before-e-except-after-cl. This function takes 4 references to vectors of strings as parameters . The first vector is the input consisting of lowercase words (only alphabetic charactersl. The next vector should be filled with words that follow the rule The next vector should be filled with words that don't have ie or...

  • C++ Language, Only the sort_i_before_e func, not included main. Also, plz look at the instructions. use...

    C++ Language, Only the sort_i_before_e func, not included main. Also, plz look at the instructions. use vector. Write a function, called "sort Lbefore e that can sort words into whether or not they conform to the 1 beforee, except after c rule, See htrps//en.oxtorddictionaries.com/spelling/-before-e-except-after-cl. This function takes 4 references to vectors of strings as parameters . The first vector is the input consisting of lowercase words (only alphabetic charactersl. The next vector should be filled with words that follow the...

  • Need help with this Home wrok question pls. For this exercise you will write code or...

    Need help with this Home wrok question pls. For this exercise you will write code or verifying usernames against a list of existing usernames. This task is known as whitelisting. It is also used as part of spam filters: spam filters that come with email clients have both whitelists and blacklists of senders and keywords to look for in emails. You are given a list of usernames that are trying to get access to a system and you need to...

  • Can you please translate this code from Java to C++; These are the only libraries i...

    Can you please translate this code from Java to C++; These are the only libraries i am allowed to use #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <string> using namespace std; 1 /* Given a string, compute recursively (no loops) a new string where all * appearances of "pi" have been replaced by "3.14". public String changepi(String str) { if(str.length() <= 1) return str; if(str.substring(0, 2).equals("pi")) return "3.14" + changepi(str.substring(2)); 11 12 return str.charAt(0) + changepi(str.substring(1)); }

  • I was wondering how to do the following. This will all be in a header file...

    I was wondering how to do the following. This will all be in a header file to be called in a .cpp file. They all have to be template functions because the .cpp file will test a few different values for each function. This should be done in C++ ====== Write a variadic template for a function named problem5 that joins an arbitrary number of strings together. This function will serve as the terminating case for two strings and your...

  • Hi, I have C++ programming problem here: Problem: Please modify your string type vector in for...

    Hi, I have C++ programming problem here: Problem: Please modify your string type vector in for push_back() function as below: void push_back(string str) { // increase vector size by one // initialize the new element with str } In addition, the standard library vector doesn't provide push_front(). Implement push_front() for your vector. Test your code with the main function below. int main() {    vector v1(3);    cout<<"v1: ";    v1.print(); // this should display -, -, -    for...

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

  • LAB 13 Please use correct division of code into .h and .cpp files and Comments in...

    LAB 13 Please use correct division of code into .h and .cpp files and Comments in code explain what's being done. Thanks you very much for your help Create an STL vector of 10 integers and store initial values (0 to 9 is fine). Use the std::random_shuffle algorithm to shuffle the list. Print the list. (use an iterator in a regular for loop) Use the std::sort algorithm to sort the list. Print the list again. (use a range-based for loop)...

  • Code in C++ Function Prototypes For the second part of the lab activity, you will be...

    Code in C++ Function Prototypes For the second part of the lab activity, you will be practicing writing function prototypes. Continue working on the same project from part A. First, rewrite the code so that you are using function prototypes for the functions getNumber.getMessage, and repeat. Remember that the prototypes go at the top of the file, followed by main, then the definitions of the three functions at the end. Second, you will be creating a new function (procedure) called...

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