Question: Write a function in C++ (named zip) that should take two const references to vector and return a vector where each element in the returned

Write a function in C++ (named "zip") that should take two const references to vector and return a vector where each element in the returned vector is the concatentation of the elements in the original two vectors (see test cases for examples). It is similar to the function called "zip_longest" in python that can merge multiple lists into a single list with the first element being each first element of the original lists.

 Write a function in C++ (named "zip") that should take two

X INPUT OF THE TEST CASE #include #include 600 vau const std::vector<:string> a_1 = {"Spartan", "Wolverine", "Husky"}; const std::vector<:string> b_1 = { "MSU", "UM"}; const std::vector<:string> c_1 = {"SpartanMSU", "WolverineUM", "Husky"}; const std::vector<:string> d_1 = { "MSUSpartan", "UMWolverine", "Husky"}; ASSERT_EQ(zip(a_1, b_1), C_1); ASSERT_EQ(zip(b_1, a_1), d_1); const std::vector<:string> a_2 = {"Apple", "Banana", "Cherry"}; const std::vector<:string> b_2 = {"Hammer", "Sickle", "Nail", "Screw" }; const std::vector<:string> c_2 = { "AppleHammer", "BananaSickle", "CherryNail", "Screw"}; 17 ASSERT_EQ( zip(a_2, b_2), c_2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!