Advertisement
Infiniti_Inter

List 74 (7) (IRA)

May 21st, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5. #include <algorithm>
  6. #include <stack>
  7. #include <queue>
  8. #include <list>
  9. using namespace std;
  10.  
  11.  
  12. ifstream fin("input.txt");
  13.  
  14.  
  15. int main()
  16. {
  17.     /*
  18.     1 2 2 3 3 3 4 4 4 4
  19.     */
  20.     list<int> l;
  21.     while (fin.peek() != EOF)
  22.     {
  23.         int cur;
  24.         fin >> cur;
  25.         if (l.empty())
  26.             l.push_back(cur);
  27.         if (cur != l.back())
  28.             l.push_back(cur);
  29.     }
  30.     while (!l.empty())
  31.     {
  32.         int cur = l.front();
  33.         l.pop_front();
  34.         cout << cur << ' ' ;
  35.     }
  36.     cout << endl;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement