MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Tuesday, April 16, 2013

using stack of c/c++ program

#include <iostream>
#include<stack>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int a;
    int k;
    while(cin>>n)
    {
        stack<int>st;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            st.push(a);
        }
        stack<int>::size_type t;
        t=st.size();
        for(int i=0;i<t;i++)
        {
            k=st.top();
            cout<<k<<" ";
            st.pop();
        }
        cout<<endl;
    }
    cout << "Hello world!" << endl;
    return 0;
}

No comments:

Post a Comment