document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include  <iostream.h>
  2. #include  <conio.h>
  3.  
  4. char stack[10];
  5. int tdc,i;
  6. char answer,tmp,e;
  7. void speed();
  8.  
  9.  
  10. void push1()
  11. {
  12.    for(i=0;i<=17; i++)
  13.     {
  14.         gotoxy(22+i,7);cout<<" ";
  15.         gotoxy(23+i,7); cout<<tmp; speed();
  16.     }
  17.      for(i=1;i<=(14-tdc);i++)
  18.      {
  19.           speed();
  20.           gotoxy(40,6+i); cout<<" ";
  21.           gotoxy(40,7+i); cout<<tmp;
  22.      }
  23. }
  24.  
  25. void pop1(char temp)
  26. {
  27.     for(i=1;i<=(14-tdc);i++)
  28.      {
  29.           speed();
  30.           gotoxy(40,22-i-tdc); cout<<" ";
  31.           gotoxy(40,21-i-tdc); cout<<tmp;
  32.      }
  33.      for(i=1;i<=19;i++)
  34.      {
  35.           speed();
  36.           gotoxy(38+i,7); cout<<" ";
  37.           gotoxy(39+i,7); cout<<tmp; speed();
  38.      }
  39.      gotoxy(58,7);cout<<" ";
  40. }
  41.  
  42. void push(char e)
  43. {
  44.      tdc=tdc+1;
  45.      stack[tdc]=e;
  46.      push1();
  47. }
  48. void pop(char e)
  49. {
  50.      if(tdc !=0)
  51.      {
  52.           gotoxy(1,7); cout<<"              "<<endl;
  53.           e=stack[tdc]; pop1(e);
  54.           tdc=tdc-1;
  55.      }
  56.      else
  57.      {
  58.           gotoxy(1,7); cout<<"stack kosong!"<<endl;
  59.           gotoxy(1,7);
  60.      }
  61. }
  62.  
  63. void main()
  64. {
  65.    clrscr();
  66.     cout<<"program stack dengan animasi"<<endl;
  67.     cout<<"1.push--> memasukkan data"<<endl;
  68.     cout<<"2.pop---> mengambil data"<<endl;
  69.     cout<<"3.clear-> membersihkan data"<<endl;
  70.     cout<<"4.exit--> keluar"<<endl;
  71.    //cout<<"pilih [1/2/3/4] ="<<endl;
  72.  
  73.  
  74.    clear:
  75.       gotoxy(59,6); cout<<"-";
  76.       gotoxy(59,9); cout<<"_";
  77.       gotoxy(37,10); cout<<"||   ||";
  78.       for(i=1;i<=11;i++)
  79.       {
  80.         gotoxy(38,10+i);
  81.        if(i==11)
  82.        cout<<"|___|";
  83.        else
  84.        cout<<"|   |";
  85.       }
  86.    tdc=0;
  87.    do
  88.    {
  89.        input:
  90.        gotoxy(1,6);
  91.        cout<<"masukkan pilihan anda[1/2/3/4] : ";
  92.        answer=getche();
  93.        if(int(answer)==27 || answer==\'4\')
  94.        break;
  95.        else if(answer==\'1\')
  96.          {
  97.       if(tdc != 7)
  98.       {
  99.             gotoxy(1,7); cout<<"masukkan suatu huruf : ";
  100.             cin>>tmp;
  101.             push(tmp);
  102.             gotoxy(1,7); cout<<"                    ";
  103.       }
  104.       else
  105.       {
  106.            gotoxy(1,7); cout<<"stack penuh!";
  107.            getch();
  108.            gotoxy(1,7); cout<<" ";
  109.          }
  110.     }
  111.    else if(answer==\'2\')
  112.    pop(tmp);
  113.    else if(answer==\'3\')
  114.    goto clear;
  115.    else
  116.    goto input;
  117.    }
  118.    while(1);
  119.  
  120.  getch();
  121. }
  122.  
  123. void speed()
  124. {
  125.      for(int y=1;y<77;y++)
  126.      for(int x=1;x<77;x++)
  127.      for(int p=1;p<77;p++)
  128.      cout<<"";
  129. }
');