fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4.  
  5. using std::cout;
  6. using std::vector;
  7. using std::list;
  8. using std::endl;
  9.  
  10.  
  11. int main(){
  12.  
  13. vector <int> iVec;
  14. list <int> iList;
  15. list <int>::iterator lIter;
  16. list <int>::reverse_iterator rIter;
  17. list <int> iList2;
  18.  
  19. for(int i=0; i<10; i++){
  20. iVec.push_back(i);
  21. iList.push_back(i);
  22. iList2.push_front(i);
  23. }
  24.  
  25.  
  26. cout << "\nVector output: \n\n";
  27. for(int i=0; i<10; i++){
  28. cout << iVec[i] <<endl; //Random access
  29. }
  30.  
  31.  
  32. cout << "\nList 1 output: \n\n";
  33. for(lIter=iList.begin(); lIter != iList.end() ; lIter++){
  34. cout << *lIter <<endl;
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41. cout << "\nList 2 output: \n\n";
  42. for(lIter=iList2.begin(); lIter != iList2.end() ; lIter++){
  43. cout << *lIter <<endl;
  44. }
  45.  
  46.  
  47.  
  48.  
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 2860KB
stdin
Standard input is empty
stdout
Vector output: 

0
1
2
3
4
5
6
7
8
9

List 1 output: 

0
1
2
3
4
5
6
7
8
9

List 2 output: 

9
8
7
6
5
4
3
2
1
0