Advertisement
Guest User

X96935 Palíndroms amb piles

a guest
Apr 26th, 2018
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n;
  7.     cin>>n;
  8.     stack<int>p;
  9.     int x;
  10.     for(int i=0; i<n; ++i){
  11.         cin>>x;
  12.         p.push(x);
  13.     }
  14.     stack<int>q;
  15.     q=p;
  16.     stack<int>r;
  17.     while(not q.empty()){
  18.         r.push(q.top());
  19.         q.pop();
  20.     }
  21.     if(r==p) cout<<"SI"<<endl;
  22.     else cout<<"NO"<<endl;
  23.    
  24. }
  25. #Si t'ha servit segueixme a insta @alexowlex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement