반응형

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
#include "stdafx.h"
int stack[100];
int top = 0;
 
int push(int value) {
    stack[top] = value; // 스택에 값을 저장
    top++// top 증가
    return top; // top 반환
}
int pop() {
    top--// top 감소
    return stack[top];  //값 반환
}
int main()
{
    push(100);
    push(200);
    push(300);
    printf("%d\n"pop());
    printf("%d\n"pop());
    printf("%d\n"pop());
 
    return 0;
}
 
cs

 

 

반응형

+ Recent posts