#include<bits/stdc++.h> using namespace std; void reverse(stack<int>&s,int data1){ if(s.empty()||s.top()<data1){ s.push(data1); }else{ int data=s.top(); s.pop(); reverse(s,data1); s.push(data); } } void Sort(stack<int>&s){ if(s.empty())return; int data=s.top(); s.pop(); Sort(s); reverse(s,data); } int main(){ stack<int>arr; arr.push(12); arr.push(122); arr.push(14); arr.push(1); arr.push(-12); Sort(arr); while(!arr.empty()){ cout<<arr.top()<<endl; arr.pop(); } }