Created
June 27, 2014 23:24
-
-
Save Onaiplee/010808c9ac82c8fa4c04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void reverse(stack<int> &st) { | |
if (!st.empty()) { | |
int temp = st.top(); | |
st.pop(); | |
reverse(st); | |
insert_botom(st, temp); | |
} | |
} | |
void insert_botom(stack<int> &st, int val) { | |
if (st.empty()) { | |
st.push(val); | |
} else { | |
int temp = st.top(); | |
st.pop(); | |
insert_botom(st, val); | |
st.push(temp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment