#include<iostream>
using namespace std;
class Stack {
public:
int stack[10];
int top = 0;
void push(int a);
void del();
};
void Stack::push(int a) {
stack[top] = a;
top++;
}
void Stack::del() {
top--;
}
int main() {
Stack s;
cout<< s.top<<endl;
s.push(10);
cout << s.stack[s.top]<<endl;
cout << s.top;
cout << endl;
s.push(100);
cout << s.stack[s.top]<<endl;
cout << s.top;
cout << endl;
s.del();
cout << s.stack[s.top]<<endl;
cout << s.top;
cout << endl;
s.del();
cout << s.stack[s.top]<<endl;
cout << s.top;
cout << endl;
s.push(50);
cout << s.stack[s.top] << endl;
cout << s.top;
cout << endl;
s.del();
cout << s.stack[s.top] << endl;
cout << s.top;
cout << endl;
s.del();
cout << s.stack[s.top] << endl;
cout << s.top;
cout << endl;
s.push(500);
cout << s.stack[s.top] << endl;
cout << s.top;
cout << endl;
return 0;
}
안돌아가요 진짜 도저히 왜안돌아가는지 모르겠는데 한번만 도와주십쇼 ㅠㅠ
뭐가 안 돌아간다는건지 정도는 알려주셔야 - return 0;
int stack이랑 top은 프라이빗 아님? 왜 퍼블릭? - return 0;
왠 자료구조
탑을 -1로 초기화하셔야 - dc App
ㅇㅇ//왠->웬 (왠지 빼고 웬임) [리듬 맞춤법 봇♬]