Question: In C++, create a solution that will create a new row whenever there's a smaller number in the vector. the first integer will create a

In C++, create a solution that will create a new row whenever there's a smaller number in the vector. the first integer will create a new row, then the second integer will be compared with the first one. If its smaller it will create a new row, but if its bigger it will continue to the next one. For example, if Vector is [5,4,6,2,7,8]

it will go as:

Row 1 =5

Row 2 = 4, 6

Row 3 = 2, 7, 8

Output the number of rows created at the end.

Test with:

a) Vector A = 5, 7, 8, 3, 2, 3

b) Vector A = 9,7,3,1,9,0

use the code provided

In C++, create a solution that will create a new row whenever

#include #include #include #include using namespace std; int solution (vector A) { // Your solution goes here. return 0; } vector int> toIntVector(string str) { std::vector int> out; std::string i; std::istringstream tokenStream(str); while (std::getline (tokenStream, i, ',')) { out.push_back(atoi(i.c_str())); } return out; } int main() { // Read in from stdin, solve the problem, and write answer to stdout. string AS; cin >> AS; vector int> A = toIntVector(AS); cout

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!