Advertisement
CLazStudio

q198418213

Feb 21st, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <list>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     srand(time(NULL));
  11.  
  12.     int n = rand()%10 + 10;
  13.     cout << n << endl;
  14.  
  15.     list<int> ls;
  16.     for (int i = 0; i < n; i++)
  17.     {
  18.         ls.push_back(rand() % 1001);
  19.         cout << ls.back() << " ";
  20.     }
  21.  
  22.     ls.remove_if([](int n){
  23.         return n > 500;
  24.     });
  25.  
  26.     cout << endl << ls.size() << endl;
  27.     for (list<int>::iterator it = ls.begin(); it != ls.end(); it++)
  28.         cout << *it << " ";
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement