Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Stack
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1,32 sec, absolute running time: 0,34 sec, absolute service time: 1,68 sec
edit mode
|
history
|
discussion
3 2 1