Advertisement
andruhovski

sp0305-c11

Feb 10th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. //Приклад 9
  2.     forward_list<int> c1, c2, c3, c4;
  3.     forward_list<int>::iterator  c1_Iter, c2_Iter, c3_Iter, w_Iter, f_Iter, l_Iter;
  4.  
  5.     c1.push_front(10);  c1.push_front(11);
  6.     c2.push_front(12);  c2.push_front(20);  c2.push_front(21);
  7.     c3.push_front(30);  c3.push_front(31);
  8.     c4.push_front(40);  c4.push_front(41);  c4.push_front(42);
  9.  
  10.     cout << "c1 =";
  11.     for (c1_Iter = c1.begin(); c1_Iter != c1.end(); c1_Iter++)
  12.         cout << " " << *c1_Iter;
  13.     cout << endl;
  14.  
  15.     cout << "c2 =";
  16.     for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
  17.         cout << " " << *c2_Iter;
  18.     cout << endl;
  19.  
  20.     w_Iter = c2.begin();
  21.     w_Iter++;
  22.     c2.splice_after(w_Iter, c1);
  23.     cout << "Після splice c1 в c2: c2 =";
  24.     for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
  25.         cout << " " << *c2_Iter;
  26.     cout << endl;
  27.    
  28.     //Приклад 10
  29.     c2.sort(greater<int>());
  30.     cout << "Після сортування c2 : c2 =";
  31.     for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
  32.         cout << " " << *c2_Iter;
  33.     cout << endl;
  34.  
  35.     cout << "c3 =";
  36.     for (c3_Iter = c3.begin(); c3_Iter != c3.end(); c3_Iter++)
  37.         cout << " " << *c3_Iter;
  38.     cout << endl;
  39.  
  40.     c2.merge(c3, greater<int>());
  41.     cout << "Після merge c3 з c2 відповідно до відношення порівння '>' : c2 =" << endl;
  42.     for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
  43.         cout << " " << *c2_Iter;
  44.     cout << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement