Skip to content

Instantly share code, notes, and snippets.

@chomado
Created August 4, 2014 08:41
Show Gist options
  • Save chomado/78638212d4912d644194 to your computer and use it in GitHub Desktop.
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
#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();
}
}
}
@chomado
Copy link
Author

chomado commented Aug 4, 2014

@chomado
Copy link
Author

chomado commented Aug 4, 2014

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