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