Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <algorithm>
- using namespace std;
- int main()
- {
- queue<int> q;
- int x;
- cin >> x;
- q.push(x); // вводишь один элемент и сразу запихиваешь в кью
- while(cin >> x){
- if(x != q.back()){ // если новый элемент не равен последнему элементу в кью, запихиваешь его в кью
- q.push(x);
- }
- }
- int n = q.size();// запоминаешь размер кью
- for(int i = 0; i < n; i++){//выводишь последовательность
- cout << q.front() << ' ';
- q.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement