| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 | 31 |
- html object
- relative path
- hyperledger transaction
- html multimedia
- #자바상속#자바이즈어#is~a
- #성적관리프로그램
- #bubbleSort
- border-box
- docker example
- html plug-in
- html video
- #다차원포인터
- html id
- #1차원배열
- html charset
- #android activity
- html5 new tag
- #JAVASCRIPT
- #C++ 연산자함수오버로딩
- git flow
- html code
- #2차원배열
- #C++ has~a
- html youtube
- #3차원배열
- #binary
- 하이퍼레저패브릭
- 토큰경제
- #CallByAddress
- mac terminal command
- Today
- Total
A sentimental robot
Stack 본문
#include<stdio.h>
int Push(struct Stack* s, int data);
int Pop(struct Stack* s, int* data);
struct Stack
{
int data[5];
int top;
};
int Push(struct Stack*s, int data){
if(s->top>=5) return 0;
s->data[s->top++]=data;
/*
s->data[s->top]=data;
s->top++;
*/
return 1;
}
int Pop(struct Stack *s, int *data){
/*
s->top--;
*data=s->data[s->top];
*/
*data=s->data[--s->top];
return 1;
}
void main()
{
Stack s = {0};
int data;
Push(&s,10);
Push(&s,20);
Push(&s,30);
Push(&s,40);
Push(&s,50);
Push(&s,60);
Pop(&s,&data); printf("data = %d\n",data); //50
Pop(&s,&data); printf("data = %d\n",data); //40
Pop(&s,&data); printf("data = %d\n",data); //30
Push(&s,70);
Push(&s,80);
Push(&s,90);
Pop(&s,&data); printf("data = %d\n",data); //90
Pop(&s,&data); printf("data = %d\n",data); //80
Pop(&s,&data); printf("data = %d\n",data); //70
Pop(&s,&data); printf("data = %d\n",data); //20
Pop(&s,&data); printf("data = %d\n",data); //10
}
'Data Structure' 카테고리의 다른 글
| Single LinkedList Exercise3 (0) | 2018.01.03 |
|---|---|
| Map에 대하여.. (0) | 2018.01.03 |
| Linear Queue (0) | 2018.01.03 |
| Babygin (0) | 2018.01.03 |
| Baseball Game(computer vs user) (0) | 2018.01.03 |