#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE 1
typedef struct NODE{
struct NODE *next;
int num;
}NODE;
NODE *top;
void push(int data);
int pop();
int isempty();
int main(){
push(1);
push(2);
printf("%d\n", pop());
push(3);
push(4);
printf("%d\n", pop());
printf("%d\n", pop());
printf("%d\n", pop());
return 0;
}
void push(int data){
struct NODE *pushnode=malloc(sizeof(struct NODE));
pushnode->num=data;
pushnode->next=top;
top=pushnode;
}
int pop(){
if(isempty())
return ;
NODE *popnode=top;
int a=popnode->num;
top=popnode->next;
free(popnode);
return a;
}
int isempty(){
if(top==NULL)
return TRUE;
else
return FALSE;
}
queue 짜다가 최적화 때문에 미루는 중..
'개발일기 > 기타' 카테고리의 다른 글
software 버전 관리 - semantic versioning (0) | 2023.07.19 |
---|---|
[vscode] 다중 주석 (0) | 2023.02.16 |
pyplot 시도 (0) | 2021.06.30 |
pyplot tutorial (0) | 2021.06.21 |
stack & queue (in c) (0) | 2021.05.17 |