stack adalah salah satu struktur data pada komputer,, disebut juga dengan tumpukan,,
jika diaplikasikan kedalam program c++
#include
#include
#include
#include
#include
int maks,top,pil,karakter,i;
int top2;
char elemen,aa,bb;
char stack[20];
char infiks[20];
char postfiks[20];
char stack2[10];
char hasil[20];
void delay();
void create(int x){
top = 0;
gotoxy(50,3);printf(” ”);
for(i=0;i<100;i++){ gotoxy(59,4+i);printf(” ”); } if(x<=20){ for(i=0;i<=x;i++){ if(i==x){ gotoxy(60,4+i);printf(“—”); } else{ gotoxy(59,4+i);printf(“| |”); } } } } void push(char aa){ gotoxy(50,2);printf(” ”); if(top == maks){ gotoxy(53,2);printf(“—-OVERFLOW—-”); } else{ stack[top]=aa; for(i=0;i<11;i++){ gotoxy(50+i,3);cout<<” “; gotoxy(51+i,3);cout<0;i–){
gotoxy(61,3+i);cout<<” “; gotoxy(61,2+i);cout<>pil;
switch(pil){
case 1:{
gotoxy(3,12);printf(“Masukan kapasitas stack (maksimal 20) : “);cin>>maks;
create(maks);
break;
}
case 2:{
if(maks==0){
gotoxy(3,12);printf(“Stack belum dibuat.Create stack terlebih dahulu”);
getch();
}
else{
gotoxy(3,12);printf(“masukan satu karakter : “);cin>>elemen;
push(elemen);
}
break;
}
case 3:{
if(maks==0){
gotoxy(3,12);printf(“Stack belum dibuat.Create stack terlebih dahulu”);
getch();
}
else{
pop();
}
break;
}
}
}
while(pil!=4);
}
void delay()
{
for(int y=1;y<100;y++)
for(int x=1;x<100;x++)
for(int p=1;p<30;p++)
cout<<”";
}
sekian dan terimakasih
jika diaplikasikan kedalam program c++
#include
#include
#include
#include
#include
int maks,top,pil,karakter,i;
int top2;
char elemen,aa,bb;
char stack[20];
char infiks[20];
char postfiks[20];
char stack2[10];
char hasil[20];
void delay();
void create(int x){
top = 0;
gotoxy(50,3);printf(” ”);
for(i=0;i<100;i++){ gotoxy(59,4+i);printf(” ”); } if(x<=20){ for(i=0;i<=x;i++){ if(i==x){ gotoxy(60,4+i);printf(“—”); } else{ gotoxy(59,4+i);printf(“| |”); } } } } void push(char aa){ gotoxy(50,2);printf(” ”); if(top == maks){ gotoxy(53,2);printf(“—-OVERFLOW—-”); } else{ stack[top]=aa; for(i=0;i<11;i++){ gotoxy(50+i,3);cout<<” “; gotoxy(51+i,3);cout<
gotoxy(61,3+i);cout<<” “; gotoxy(61,2+i);cout<
switch(pil){
case 1:{
gotoxy(3,12);printf(“Masukan kapasitas stack (maksimal 20) : “);cin>>maks;
create(maks);
break;
}
case 2:{
if(maks==0){
gotoxy(3,12);printf(“Stack belum dibuat.Create stack terlebih dahulu”);
getch();
}
else{
gotoxy(3,12);printf(“masukan satu karakter : “);cin>>elemen;
push(elemen);
}
break;
}
case 3:{
if(maks==0){
gotoxy(3,12);printf(“Stack belum dibuat.Create stack terlebih dahulu”);
getch();
}
else{
pop();
}
break;
}
}
}
while(pil!=4);
}
void delay()
{
for(int y=1;y<100;y++)
for(int x=1;x<100;x++)
for(int p=1;p<30;p++)
cout<<”";
}
sekian dan terimakasih
0 komentar:
Posting Komentar