Advertisement
KrimsN

Untitled

Oct 30th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include "iostream"
  2. #include "iterator"
  3. #include "list"
  4. using namespace std;
  5.  
  6. struct list_
  7. {
  8.     double x;
  9.     list_ *prev, *next;
  10. };
  11.  
  12. class tlist
  13. {
  14. public:
  15.     list <double> list__;
  16.     list <double> :: iterator pos_i_, pos_i, pos_N_i;
  17.     tlist(int N)
  18.     {
  19.         double buf = 1;
  20.         for (int i = 0; i < N; ++i)
  21.         {
  22.             std::cout << "������� x_" << i + 1 << " : ";
  23.             std::cin >> buf;
  24.             list__.push_back(buf);
  25.         }
  26.  
  27.         pos_i = list__.begin();
  28.         pos_N_i = list__.end();
  29.  
  30.     }
  31.     double GetFromBegin(int i)
  32.     {
  33.         pos_i = list__.begin();
  34.         advance(pos_i, i);
  35.         int A = *pos_i;
  36.         return A;
  37.     }
  38.     double GetFromEnd(int i)
  39.     {
  40.         pos_N_i = list__.end();
  41.         advance(pos_N_i, -i);
  42.         int A = *pos_N_i;
  43.         return A;
  44.     }
  45.     ~tlist()
  46.     {
  47.         list__.erase(list__.begin() , list__.end());
  48.         //cout << "! ! !   ����������   ! ! !" << endl;
  49.     }
  50.    
  51. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement