Bob103

Дубль

Jun 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include "stack.h"
  3. #include <fstream>
  4.  
  5. ifstream in("input.txt");
  6. ofstream out("output.txt");
  7.  
  8. int main(){
  9. Stack<int> input;
  10. Stack<int> output;
  11. int n, tmp = 0;
  12. in >> n;
  13.  
  14. for (int i = 0; i < n; i++){
  15. in >> tmp;
  16. input.Push(tmp);
  17. }
  18.  
  19. bool set = true;
  20. while (!input.Empty()){
  21. if (input.Top() != tmp || set){
  22. tmp = input.Top();
  23. output.Push(tmp);
  24. set = false;
  25. }
  26. input.Pop();
  27. }
  28. while (!output.Empty()){
  29. out << output.Top() << " ";
  30. output.Pop();
  31. }
  32.  
  33. out << endl;
  34. in.close();
  35. out.close();
  36. return 0;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment