Advertisement
pseudocreator

go2 list create, insert

Apr 1st, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     srand(time(NULL));
  11.     int k=7;
  12.  
  13.     std::list<int> *mylist = new std::list<int>[k];
  14.  
  15.     std::list<int>::iterator *it = new std::list<int>::iterator[k];
  16.  
  17.    for(int i = 0;  i < k; i++){
  18.    int k = rand() % 19 + 1;
  19.     it[i] = mylist[i].begin();
  20.     for(int j = 0; j < 10; j++){
  21.         mylist[i].insert(it[i], k+j);
  22.     }
  23.  
  24.    }
  25.  
  26.     for(int i = 0; i < k; i++){
  27.     cout<<"Lista " << i <<" : ";
  28.         for(it[i] = mylist[i].begin(); it[i] != mylist[i].end(); it[i]++){
  29.             cout << " "<<*it[i];
  30.         }
  31.         cout << endl;
  32.     }
  33.  
  34.  
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement