Created
January 25, 2019 17:51
-
-
Save emirozturk/65e1523e7ccb04b14d4a9010fe55b1bb to your computer and use it in GitHub Desktop.
Veri Yapıları Stack Uygulaması 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int stack[10]; | |
int sp=0; | |
void pop() | |
{ | |
if(sp == 0) | |
printf("Stack bos.\n"); | |
else | |
printf("Deger:%d\n",stack[--sp]); | |
} | |
void push() | |
{ | |
if(sp<10) | |
{ | |
int eleman = 0; | |
printf("Eleman:");scanf("%d",&eleman); | |
stack[sp++]=eleman; | |
} | |
else | |
printf("Stack Dolu.\n"); | |
} | |
void listele() | |
{ | |
for(int i=sp-1;i>=0;i--) | |
printf("|%3d|\n",stack[i]); | |
} | |
void menu() | |
{ | |
int secim = 0; | |
do | |
{ | |
listele(); | |
printf("1.Push\n"); | |
printf("2.Pop\n"); | |
printf("3.Cikis\n"); | |
printf("Secim:");scanf("%d",&secim); | |
if(secim == 1)push(); | |
if(secim == 2)pop(); | |
}while(secim != 3); | |
} | |
int main(int argc, const char * argv[]) | |
{ | |
menu(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment