Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "stack.h"
- #include <fstream>
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main(){
- Stack<int> input;
- Stack<int> output;
- int n, tmp = 0;
- in >> n;
- for (int i = 0; i < n; i++){
- in >> tmp;
- input.Push(tmp);
- }
- bool set = true;
- while (!input.Empty()){
- if (input.Top() != tmp || set){
- tmp = input.Top();
- output.Push(tmp);
- set = false;
- }
- input.Pop();
- }
- while (!output.Empty()){
- out << output.Top() << " ";
- output.Pop();
- }
- out << endl;
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment