Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- #include<vector>
- #include<random>
- using namespace std;
- vector<int> Vector(15), Vector2(15);
- int n = 15;
- int count1 = 0;
- int Randaa()
- {
- return (rand() % 16);
- }
- int main()
- {
- generate(Vector.begin(), Vector.end(), Randaa);//paste of random numbers
- cout << "<Vector>::";
- for_each(Vector.begin(), Vector.end(), [](int i) {cout << " " << i; });
- cout << endl;
- copy(Vector.begin(), Vector.end(), Vector2.begin());//copy the vector
- cout << "<Vector2> ::";
- for_each(Vector2.begin(), Vector2.end(), [](int i) {cout << " " << i; });
- cout << endl;
- random_shuffle(Vector2.begin(), Vector2.end());//mix the vector2
- cout << "Mix of the <Vector2> ::";
- for_each(Vector2.begin(), Vector2.end(), [](int i) {cout << " " << i; });
- for_each(Vector2.begin(), Vector2.end(), [](int i) {count1 += i; });
- int sr;
- sr = count1 / n;
- cout << "\nmean value = " << sr<<endl;
- transform(Vector.begin(), Vector.end(), Vector2.begin(),Vector.begin(), multiplies<int>());
- cout << "The element-wise products of vectors \n are: ";
- for_each(Vector.begin(), Vector.end(), [](int i) {cout << " " << i; });//* elements
- cout << "\n"<<"square of elements Vector = ";
- for_each(Vector.begin(), Vector.end(), [](int& sqr) {sqr = pow(sqr, 2); });
- for_each(Vector.begin(), Vector.end(), [](int sqr) {cout << " " << sqr; });// square of elements
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement