#include<iostream.h>
char stk[10];
int hj=0;
void push(char a)
{stk[hj]=a;
hj++;}
char pop()
{hj--;
return(stk[hj]);}
void cetak()
{cout<<"Stack = ";
for(int i=0;i<hj;i++)
cout<<stk[i]<<" ";
cout<<endl<<endl;}
main()
{char x; int upil;
do {cout<<"STACK\n1. Push\n2. Pop\n3. Selesai\nPilihan Anda : ";
cin>>upil;
switch (upil)
{case 1:
{cout<<"Masukkan : ";cin>>x;push (x);cetak();break;}
case 2:
{pop();cetak();break;}
case 3:
{cout<<"Program selesai, silahkan tutup program ini.";break;}
default:
cout<<"Pilihan anda salah."<<endl<<endl;}
}
while (upil!=3);
}
{ 0 komentar... Views All / Send Comment! }
Posting Komentar