Program Animasi Stack Push – Pop Pada Turbo C++


Stack Push-Pop

Stack Push-Pop

Pada Postingan ini saya akan membuat program animasi stack push-pop pada Turbo C++ untuk melengkapi program yang telah diberikan oleh dosen saya pada mata kuliah Pemograman Berorientasi Objek. Nah untuk source codenya silahkan langsung anda coba di Laptop atau komputer anda

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

int top,i;
char key,temp,e;
char stack[10];
void delay();

void pushmardin()
{
for(i=0;i<=17; i++)
{
gotoxy(22+i,7);cout<<" ";
gotoxy(23+i,7); cout<<temp; delay();
}
for(i=1;i<=(14-top);i++)
{
delay();
gotoxy(40,6+i); cout<<" ";
gotoxy(40,7+i); cout<<temp;
}
}
void popmardin(char temp)
{
for(i=1;i<=(14-top);i++)
{
delay();
gotoxy(40,22-i-top);cout<<"";
gotoxy(40,21-i-top);cout<<temp;
}
for(i=1;i<=19;i++)
{
delay();
gotoxy(38+i,7);cout<<"";
gotoxy(39+i,7);cout<<temp;delay();
}
gotoxy(58,7);cout<<"";
}
void push(char e)
{
top=top+1;
stack[top]=e;
pushmardin();
}
void pop(char e)
{
if(top!=0)
{
e=stack[top];popmardin(e);
top=top-1;
}
else
{
gotoxy(1,7);cout<<"Stack Telah Kosong"<<endl;

gotoxy(1,7);
}
}
void main()
{
clrscr();
cout<<“Animasi Stack Versi Lesmardin”<<endl;
cout<<“1.Push”<<endl;
cout<<“2.Pop”<<endl;
cout<<“3.Close”<<endl;
gotoxy(59,6); cout<<“=”;
gotoxy(59,8); cout<<“=”;
gotoxy(37,9); cout<<“|| ||”;
for(i=1;i<=11;i++)
{
gotoxy(38,10+i);
if(i==11)
cout<<“|___|”;
else
cout<<“| |”;
}
top=0;
do
{
input:
gotoxy(1,5);
cout<<“Masukkan Pilihan Anda[1/2/3] : “;
key=getche();
if(int(key)==27 || key==’3′)
break;
else if(key==’1′)
{
if(top != 10)
{
gotoxy(1,7); cout<<“Input Suatu Huruf : “;
cin>>temp;
push(temp);
gotoxy(1,7); cout<<” “;
}
else
{
gotoxy(1,7); cout<<“Kepenuhan Boss”;
getch();
gotoxy(1,7); cout<<” “;
}
}
else if(key==’2′)
pop(temp);
else
goto input;
}while(1);
getch();
}
void delay()
{

for(int y=1;y<100;y++)
for(int x=1;x<100;x++)
for(int p=1;p<100;p++)
cout<<“”;
}

Semoga bermanfaat buat anda πŸ˜€

Advertisements

3 responses to “Program Animasi Stack Push – Pop Pada Turbo C++

  1. gotoxy(40,7+i);cout<<temp; error bro,..

    Like

  2. klo dari wordpress langsung di copy memang error, coba ketik manual
    πŸ˜›

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s