Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <stack>
- #include <queue>
- using namespace std;
- ifstream fin("input.txt");
- int main()
- {
- /*
- 1 2 2 3 3 3 4 4 4 4
- */
- stack<int> s;
- while (fin.peek() != EOF)
- {
- int cur;
- fin >> cur;
- if (s.empty() || s.top() != cur)
- s.push(cur);
- }
- while (!s.empty())
- {
- int cur = s.top();
- s.pop();
- cout << cur << ' ';
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement