#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define max 7
//deklarasi struct stack
struct STACK
{
char data[max+1];
int atas;
};
STACK tumpuk; //deklarasi struct tumpuk
char conv[100],baru,temp;
int pilih,n,i;
// Prototype Fungsi
int intValidation(char chrInp[]);
void push();
void pop();
void intro();
void delay();
void animasi_push();
void animasi_pop();
void pembukaan();
//program utama
void main()
{
pembukaan();
intro();
clrscr();
cout << " ==================================== \n";
cout << " Program Tumpukan (Stack) \n";
cout << " ==================================== \n\n";
cout << "-------------------------------------------------------------------------------\n";
cout << "1. Push Data (Tambah Data)\n";
cout << "2. Pop Data (Hapus Data)\n";
cout << "3. Keluar\n";
cout << "-------------------------------------------------------------------------------\n";
cout << " \n";
cout << " \n";
cout << " X DELETE \n";
cout << " ======= \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " ======= \n";
cout << " \n";
cout << " ~Data Tumpukan~ \n";
awal :
gotoxy(1,10);
cout<<" ";
gotoxy(1,11);
cout<<" ";
gotoxy(1,10);
cout << "Pilih : ";
gets(conv);
//pemanggilan fungsi validasi
if(!intValidation(conv)){ cout<<"Input tidak boleh berupa karakter.."; getch(); goto awal; }
pilih=atoi(conv);
//seleksi terhadap pilihan
switch (pilih)
{
case 1:
push();
goto awal;
case 2:
pop();
goto awal;
case 3:
cout << "Terimakasih Telah Mencoba Program Ini";
intro();
exit(1);
default:
cout << "Id Menu Tidak Ada Pada List";
getch();
goto awal;
break;
}
}
//fungsi push atau tambah data
void push()
{
//seleksi apabila jumlah data pada tumpukan penuh
if(tumpuk.atas==max)
{
gotoxy(1,11);
cout<<"Tumpukan Penuh";
getch();
}
else
{
gotoxy(1,11);
cout<<"Data yang akan di Push (Char) : \n";
cin>>baru;
tumpuk.atas++ ;
//input data pada struck tumpuk
tumpuk.data[tumpuk.atas]=baru;
//memanggil fungsi animasi push
animasi_push();
}
}
//fungsi pop atau menghapus data teratas pada tumpukan
void pop()
{
//seleksi bila data di tumpukan masih kosong
if (tumpuk.atas==NULL)
{
gotoxy(1,11);
cout<<"Tumpukan Kosong";
getch();
}
else
{
cout<<"Data yang akan di pop = "<<tumpuk.data[tumpuk.atas];
temp = tumpuk.data[tumpuk.atas];
//nilai tumpuk.atas dikurangi untuk menghapus ke-tumpuk.atas
tumpuk.atas--;
//memanggil fungsi animasi pop
animasi_pop();
}
}
//fungsi validasi
int intValidation(char chrInp[])
{
int i;
//loop untuk memeriksa isi data
for(i=0;i<strlen(chrInp);i++){
if(!isdigit(chrInp[i]))
{
return 0;
break;
}
}
return 1;
}
//fungsi animasi push
void animasi_push()
{
int x=1,y=12;
for(x;x<=39;x++)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(x==39)
{
gotoxy(x+1,y);
cout<<tumpuk.data[tumpuk.atas];
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
}
}
for(y;y<=21-tumpuk.atas;y++)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(y==21-tumpuk.atas)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<"======= ";
}
}
}
//fungsi animasi pop
void animasi_pop()
{
int x=40,y=20-tumpuk.atas;
for(y;y>=13;y--)
{
gotoxy(x,y);
cout<<temp;
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(y==14)
{
gotoxy(x,y);
cout<<temp;
delay(); delay(); delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
gotoxy(x,y);
cout<<" ";
delay();
}
}
for(x;x<=65;x++)
{
gotoxy(x,y);
cout<<temp;
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(x==65)
{
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<"======= ";
}
}
}
//fungsi tampilan pada pembukaan program
void pembukaan()
{
cout<<"===============================================================================\n";
cout<<"===============================================================================\n";
cout<<" \n";
cout<<" Loading ........ \n";
cout<<" \n";
cout<<" =============================================== \n";
cout<<" | | \n";
cout<<" | Program Tumpukan (Dengan Array) | \n";
cout<<" | | \n";
cout<<" =============================================== \n";
cout<<" \n";
cout<<" \n";
cout<<" Oleh : \n";
cout<<" \n";
cout<<" KELOMPOK 15 \n";
cout<<" \n";
cout<<" 1. Rai Gudakesa 1004505005 \n";
cout<<" 2. I Komang Ariana 1004505015 \n";
cout<<" 3. Komang Arya Senatana Budi 1004505027 \n";
cout<<" 4. Nym. Agus Tria Surya Kurniawan 1004505028 \n";
cout<<" \n";
cout<<" \n";
cout<<" \n";
cout<<"===============================================================================\n";
cout<<"===============================================================================";
int x = 17, y=6,c,d,a,e;
for(a=1;a<2;a++)
{
for (x;x<64;x++)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"=";
}
x = 63, y=7;
for (y;y<11;y++)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"|";
}
x = 63, y=10;
for (x;x>16;x--)
{
gotoxy(x-2,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"=";
}
x = 17, y=9;
for (y;y>6;y--)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"|";
}
}
}
//fungsi intro
void intro()
{
int x,y;
for(x=1;x<=78;x=x+3)
{
for(y=1;y<=25;y++)
{
gotoxy(x,y);
cout<<"===";
for(int a=1;a<80;a++)
for(int b=1;b<80;b++)
cout<<"";
}
for(int a=1;a<80;a++)
for(int b=1;b<800;b++)
cout<<"";
}
delay();
}
//fungsi delay
void delay()
{
int a,b;
for(a=1;a<1000;a++)
for(b=1;b<1000;b++)
cout<<"";
}
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define max 7
//deklarasi struct stack
struct STACK
{
char data[max+1];
int atas;
};
STACK tumpuk; //deklarasi struct tumpuk
char conv[100],baru,temp;
int pilih,n,i;
// Prototype Fungsi
int intValidation(char chrInp[]);
void push();
void pop();
void intro();
void delay();
void animasi_push();
void animasi_pop();
void pembukaan();
//program utama
void main()
{
pembukaan();
intro();
clrscr();
cout << " ==================================== \n";
cout << " Program Tumpukan (Stack) \n";
cout << " ==================================== \n\n";
cout << "-------------------------------------------------------------------------------\n";
cout << "1. Push Data (Tambah Data)\n";
cout << "2. Pop Data (Hapus Data)\n";
cout << "3. Keluar\n";
cout << "-------------------------------------------------------------------------------\n";
cout << " \n";
cout << " \n";
cout << " X DELETE \n";
cout << " ======= \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " || || \n";
cout << " ======= \n";
cout << " \n";
cout << " ~Data Tumpukan~ \n";
awal :
gotoxy(1,10);
cout<<" ";
gotoxy(1,11);
cout<<" ";
gotoxy(1,10);
cout << "Pilih : ";
gets(conv);
//pemanggilan fungsi validasi
if(!intValidation(conv)){ cout<<"Input tidak boleh berupa karakter.."; getch(); goto awal; }
pilih=atoi(conv);
//seleksi terhadap pilihan
switch (pilih)
{
case 1:
push();
goto awal;
case 2:
pop();
goto awal;
case 3:
cout << "Terimakasih Telah Mencoba Program Ini";
intro();
exit(1);
default:
cout << "Id Menu Tidak Ada Pada List";
getch();
goto awal;
break;
}
}
//fungsi push atau tambah data
void push()
{
//seleksi apabila jumlah data pada tumpukan penuh
if(tumpuk.atas==max)
{
gotoxy(1,11);
cout<<"Tumpukan Penuh";
getch();
}
else
{
gotoxy(1,11);
cout<<"Data yang akan di Push (Char) : \n";
cin>>baru;
tumpuk.atas++ ;
//input data pada struck tumpuk
tumpuk.data[tumpuk.atas]=baru;
//memanggil fungsi animasi push
animasi_push();
}
}
//fungsi pop atau menghapus data teratas pada tumpukan
void pop()
{
//seleksi bila data di tumpukan masih kosong
if (tumpuk.atas==NULL)
{
gotoxy(1,11);
cout<<"Tumpukan Kosong";
getch();
}
else
{
cout<<"Data yang akan di pop = "<<tumpuk.data[tumpuk.atas];
temp = tumpuk.data[tumpuk.atas];
//nilai tumpuk.atas dikurangi untuk menghapus ke-tumpuk.atas
tumpuk.atas--;
//memanggil fungsi animasi pop
animasi_pop();
}
}
//fungsi validasi
int intValidation(char chrInp[])
{
int i;
//loop untuk memeriksa isi data
for(i=0;i<strlen(chrInp);i++){
if(!isdigit(chrInp[i]))
{
return 0;
break;
}
}
return 1;
}
//fungsi animasi push
void animasi_push()
{
int x=1,y=12;
for(x;x<=39;x++)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(x==39)
{
gotoxy(x+1,y);
cout<<tumpuk.data[tumpuk.atas];
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
}
}
for(y;y<=21-tumpuk.atas;y++)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(y==21-tumpuk.atas)
{
gotoxy(x,y);
cout<<tumpuk.data[tumpuk.atas];
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<"======= ";
}
}
}
//fungsi animasi pop
void animasi_pop()
{
int x=40,y=20-tumpuk.atas;
for(y;y>=13;y--)
{
gotoxy(x,y);
cout<<temp;
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(y==14)
{
gotoxy(x,y);
cout<<temp;
delay(); delay(); delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ========";
gotoxy(x,y);
cout<<" ";
delay();
}
}
for(x;x<=65;x++)
{
gotoxy(x,y);
cout<<temp;
delay(); delay();
gotoxy(x,y);
cout<<" ";
if(x==65)
{
gotoxy(37,13);
cout<<" ========";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<" ======== ";
delay();
gotoxy(37,13);
cout<<"======= ";
}
}
}
//fungsi tampilan pada pembukaan program
void pembukaan()
{
cout<<"===============================================================================\n";
cout<<"===============================================================================\n";
cout<<" \n";
cout<<" Loading ........ \n";
cout<<" \n";
cout<<" =============================================== \n";
cout<<" | | \n";
cout<<" | Program Tumpukan (Dengan Array) | \n";
cout<<" | | \n";
cout<<" =============================================== \n";
cout<<" \n";
cout<<" \n";
cout<<" Oleh : \n";
cout<<" \n";
cout<<" KELOMPOK 15 \n";
cout<<" \n";
cout<<" 1. Rai Gudakesa 1004505005 \n";
cout<<" 2. I Komang Ariana 1004505015 \n";
cout<<" 3. Komang Arya Senatana Budi 1004505027 \n";
cout<<" 4. Nym. Agus Tria Surya Kurniawan 1004505028 \n";
cout<<" \n";
cout<<" \n";
cout<<" \n";
cout<<"===============================================================================\n";
cout<<"===============================================================================";
int x = 17, y=6,c,d,a,e;
for(a=1;a<2;a++)
{
for (x;x<64;x++)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"=";
}
x = 63, y=7;
for (y;y<11;y++)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"|";
}
x = 63, y=10;
for (x;x>16;x--)
{
gotoxy(x-2,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"=";
}
x = 17, y=9;
for (y;y>6;y--)
{
gotoxy(x,y);
cout<<" ";
delay();
gotoxy(x,y);
cout<<"|";
}
}
}
//fungsi intro
void intro()
{
int x,y;
for(x=1;x<=78;x=x+3)
{
for(y=1;y<=25;y++)
{
gotoxy(x,y);
cout<<"===";
for(int a=1;a<80;a++)
for(int b=1;b<80;b++)
cout<<"";
}
for(int a=1;a<80;a++)
for(int b=1;b<800;b++)
cout<<"";
}
delay();
}
//fungsi delay
void delay()
{
int a,b;
for(a=1;a<1000;a++)
for(b=1;b<1000;b++)
cout<<"";
}