Advertisement
dimon-torchila

Untitled

Dec 28th, 2021
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. void PrintVector(vector<int>& v)
  6. {
  7.     for (auto x : v)
  8.         cout << x << ' ';
  9.     cout << endl;
  10. }
  11.  
  12. int main()
  13. {
  14.     srand(time(0));
  15.     int n,k = 0;
  16.     cin >> n;
  17.     vector<int> array;
  18.     for (int i = 0; i < n; i++)
  19.     {
  20.         int b = rand() % 5;
  21.         array.push_back(b);
  22.     }
  23.     PrintVector(array);
  24.     array.erase(remove(array.begin(), array.end(), 0),array.end());
  25.     PrintVector(array);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement