-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
스택의 구현
- 크게 어려운 부분은 없었으나
int MX = 1000005;
int data[MX];
int head = 0, tail = 0;
if (command == "back") {
if (tail - head != 0) cout << data[tail-1] << '\n';
else cout << -1 << '\n';
}- 가장 마지막 원소에 접근할 때는 tail-1이다!
- tail은 항상 마지막 원소 다음을 가리키고 있기 때문에 값이 비어있다. (혹은 쓰레기값이 들어있지렁이)
Reactions are currently unavailable