Question: The existing code below reads in a random seed and generates a sequence of numbers in the vector vec . It then makes a second
The existing code below reads in a random seed and generates a sequence of numbers in the vector vec. It then makes a second vector, vec2, that is the same size (filled with 0s). It then prints both. Before they are printed, use the transform algorithm to fill vec2 so that each value = c^2 - 1 where c is the corresponding value in vec. A squareMinusOne function is already written - you can use it in your transform call.
Code:
#include
using namespace std;
int squareMinusOne(int x) { return x * x - 1; }
int main() { //Fill vector with random numbers 1-10 int seed; cin >> seed; srand(seed);
vector
//Make another vector and size it to match first vector vector
//Do not modify anything on or above the line below this //YOUR_CODE_BELOW
//YOUR_CODE
//YOUR_CODE_ABOVE //Do not modify anything on or below the line above this
//Print the vector for(int i : vec) cout << i << " "; cout << endl;
//Print the second vector for(int i : vec2) cout << i << " "; cout << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
