#include<bits/stdc++.h>
using namespace std;
int main(){
    stack<int> s;
    int input;
    while(cin>>input){
        s.push(input);
    }
    vector<int> v;
    while(s.empty()==0){
        v.push_back(s.top());
        s.pop();
    }
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";    //here the elements of stack 1 2 3 4 5 6 will store in vector
                            //as 6 5 4 3 2 1
    }
    cout<<"\n";
    for(int i=v.size()-1;i>=0;i--){
        cout<<v[i]<<" "; 
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: