Skip to content

Instantly share code, notes, and snippets.

@emirozturk
Created January 25, 2019 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emirozturk/65e1523e7ccb04b14d4a9010fe55b1bb to your computer and use it in GitHub Desktop.
Save emirozturk/65e1523e7ccb04b14d4a9010fe55b1bb to your computer and use it in GitHub Desktop.
Veri Yapıları Stack Uygulaması 2016
#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