Advertisement
dllbridge

Untitled

Apr 30th, 2025
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include<iostream>
  5. #include <List>
  6. using namespace std;
  7.  
  8.  
  9.  
  10. /////////////////////////////////////////////
  11. int  main()
  12. {
  13.  
  14.  list <int> q;
  15.  //     *       *       *       *        *
  16.  int mas[20] = { 3,  2, 44,  5, 65, 32, 11, 20, 84,  32,
  17.        33, 22, 42, 53, 35, 31, 14, 26, 24, 442 };
  18.  
  19.  list<int>::iterator it;
  20.  it = q.begin();
  21.  
  22.  for (int i = 0; i < 20; i++)
  23.  {
  24.  
  25.   if (i % 2 != 0)
  26.   {
  27.  
  28.      q.push_back(mas[i]);
  29.   }
  30.  
  31.  }
  32.  
  33.  cout << "Size of q = " << q.size() << endl;
  34.  
  35.  int  i = 0;
  36.  
  37.  
  38.   while (i <= q.size())
  39.   {
  40.  
  41.      cout << *it << endl;
  42.      i++;
  43.      it++;
  44.   }
  45.  
  46.  /*
  47.  while (it != q.end())
  48.  {
  49.  
  50.   cout << *it << endl;
  51.   i++;
  52.   it++;
  53.  }
  54.  */
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement