일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 youtube
- border-box
- #3차원배열
- #C++ has~a
- #JAVASCRIPT
- html plug-in
- html object
- html code
- html id
- #다차원포인터
- 토큰경제
- docker example
- #android activity
- #자바상속#자바이즈어#is~a
- html5 new tag
- html video
- #binary
- #CallByAddress
- #1차원배열
- html multimedia
- html charset
- mac terminal command
- relative path
- git flow
- #2차원배열
- 하이퍼레저패브릭
- #C++ 연산자함수오버로딩
- #bubbleSort
- #성적관리프로그램
- hyperledger transaction
- 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 |