Created
August 4, 2014 08:41
-
-
Save chomado/78638212d4912d644194 to your computer and use it in GitHub Desktop.
[AOJ]行き止まりの道路に車が云々とかだけど要するにただのstack http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013
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
#include <iostream> | |
#include <stack> | |
using namespace std; | |
int main() | |
{ | |
stack<int> stk; | |
int car; | |
while (cin >> car) { | |
if (car) { | |
stk.push(car); | |
} | |
else { | |
cout << stk.top() << endl; | |
stk.pop(); | |
} | |
} | |
} |
Sample Input
1
6
0
8
10
0
0
0
Output for the Sample Input
6
10
8
1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
accepted: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1035956