Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Stack
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <stdio.h> #include <stdlib.h> #define MAX_STACK_SIZE 100 typedef int element; typedef struct { element data[MAX_STACK_SIZE]; int top; }StackType; void init_stack(StackType *s) { s->top = -1; } int is_empty(StackType *s) { return (s->top == -1); } int is_full(StackType *s) { return(s->top == MAX_STACK_SIZE - 1 ); } void push(StackType *s,element item) { if(is_full(s)) { fprintf(stderr,"스택이 꽉 찼습니다."); exit(1); } else s->data[++(s->top)] = item; } element pop(StackType *s) { if(is_empty(s)) { fprintf(stderr,"스택이 비었습니다."); exit(1); } else return s->data[(s->top)--]; } int main(void) { StackType *s; s = (StackType *) malloc (sizeof(StackType)); init_stack(s); push(s,1); push(s,2); push(s,3); printf("%d\n",pop(s)); printf("%d\n",pop(s)); printf("%d\n",pop(s)); free(s); return 0; }
run
|
edit
|
history
|
help
0
BPC cv 5_Test
TVector
BPC UDP cv10 cisla
prestupny rok
kamo discriminant oprava
problema5propuestos2014/11/05
arraywithqueue
BPC cv5_kvadraticka - final
Fractions n/d that obey (n+5)/(d+2)=3n/d
matice