Sabtu, 04 Januari 2014

Program Stack

#include <iostream.h>
#include<stdio.h>
#define MAX 5
#define true 1
#define false 0

char stack[MAX];
int top;

void init(void);
int full(void);
int empty(void);
char pop(void);
void clear(void);
void push(char info);
void baca(void);

void main()
{
char pilih,elm;
cout<<"demo operasi single stack"<<endl;
init();
do
{
system ("COLOR A");
cout<<"OPERASI SINGLE STACK :\n\n";
cout<<"[1]PUSH"<<endl;
cout<<"[2]POP"<<endl;
cout<<"[3]clear"<<endl;
cout<<"[4]BACA"<<endl;
cout<<"[5]selesai"<<endl;
cout<<"\n\npilihan:";cin>>pilih;
switch(pilih)
{
case '1':cout<<"PUSH-->";cin>>elm;
push(elm);
break;
case '2':elm=pop();
cout<<"pop"<<elm;
break;
case '3':clear();
break;
case '4':baca();
break;
case '5':break;
default:cout<<"salah pilih..."<<endl;
}
cout<<endl;
}
while(pilih!='5');
}

void init(void)
{
top=0;
}
void push(char info)
{
if(full()!=true)
{
top++;
stack[top]=info;
}
else
cout<<"stack overflow..."<<endl;
}
char pop(void)
{
char info;
if(empty()!=true)
{
info=stack[top];
top--;
return(info);
}
else
cout<<"stack underflow..."<<endl;
}
void clear(void)
{
top=0;
}
int full(void)
{
if(top==MAX)
return(true);
else
return(false);
}
int empty(void)
{
if(top==0)
return(true);
else
return(false);
}
void baca(void)
{ int i;
cout<<"\n\nisi stack: ";

if(top>0)
{
for(i=1;i<=top;i++)
cout<<stack[i]<<" ";
}
else
cout<<"\n(kosong)\n";
cout<<endl;
}

Minggu, 03 November 2013

Program Berjalan

//---------------------------------------------------------------------------
#pragma hdrstop
#include <stdio.h>
#include <conio.h>
//---------------------------------------------------------------------------
//prosedur untuk menggerakkan kalimat dengan memanfaatkan perintah for
//prosedur gerak1 dari kiri ke kanan
void gerak1()
{
int i,x,y,d;
for(i=1;i<=60;i++)
{
clrscr();
for(d=1;d<=500;d++){gotoxy(i,3);printf("Rahmat Fajriyansah");}
}
}//akhir prosedur gerak1
//prosedur untuk menggerakkan kalimat dengan memanfaatkan perintah for
//prosedur gerak2 dari kanan ke kiri
void gerak2()
{
printf("Belum ada programnya, silahkan dibuat sendiri !");
}//akhir prosedur gerak2
//prosedur untuk menggerakkan kalimat dengan memanfaatkan perintah for
//prosedur gerak3 dari atas ke bawah
void gerak3()
{
int i,x,y,d;
for(i=1;i<=20;i++)
{
clrscr();
for(d=1;d<=500;d++){gotoxy(3,i);printf("Rahmat Fajriyansah");}
}
}//akhir prosedur gerak3
//prosedur untuk menggerakkan kalimat dengan memanfaatkan perintah for
//prosedur gerak4 dari bawah ke atas
void gerak4()
{
printf("Belum ada programnya, silahkan dibuat sendiri !");
}//akhir prosedur gerak4
//PROGRAM UTAMA
int main()
{
int ulang,pil;
ulang=4;
do
{
clrscr();
printf("MENU UTAMA\n");
printf("==========\n");
printf("1. Prosedur gerak1 kiri ke kanan\n");
printf("2. Prosedur gerak2 kanan ke kiri\n");
printf("3. Prosedur gerak3 atas ke bawah\n");
printf("4. Prosedur gerak4 bawah ke atas \n");
printf("5. Selesai\n\n");
printf("Tentukan pilihan anda :");scanf("%d",&pil);
switch(pil)
{
case 1 :
clrscr(); gerak1(); getch();
break;
case 2 :
clrscr(); gerak2(); getch();
break;
case 3 :
clrscr(); gerak3(); getch();
break;
case 4 :
clrscr(); gerak4(); getch();
break;
case 5 :
return(0);
}
}while (ulang!=0);
return(0);
}

Program Pembayaran Hotel

#include<conio.h>
#include<iostream.h>
pemesanan(int kode,int lama);
main()
{
char pelanggan[67],kode;
int lama,garis;
cout<<"============================================================="<<endl;
cout<<"|\t\t\t HOTEL COY\t\t\t    |"<<endl<<endl;
cout<<"|\t jl.baker street no 21  km 03 LLG tel<081995260195> |"<<endl;
cout<<"============================================================="<<endl<<endl;
cout<<"\tMasukkan Nama penghuni       : "; cin>>pelanggan;
cout<<"\tMasukkan kode kamar (k/s/m)  : "; cin>>kode;
cout<<"\tMasukkan lama menginap       : "; cin>>lama;
pemesanan(kode,lama);
getch();
}
pemesanan(kode,lama)
{
if((kode =='k')||(kode=='K'))
{
int lamaa;
cout<<"\tNama Kamar yang di sewa      : Mawar "<<endl;
lamaa=lama*20000;
cout<<"============================================================="<<endl;
cout<<"\tJumlah Biaya                 : "<<lamaa<<endl;
cout<<"============================================================="<<endl;
cout<<"\n\t\t\t TERIMA KASIH";
}
else if ((kode =='s')||(kode=='S'))
{
int lamaa;
cout<<"Nama kamar yang di sewa     : Kamboja "<<endl;
lamaa = lama * 25000;
cout<<"============================================================="<<endl;
cout<<"Jumlah Biaya                 : "<<lamaa<<endl;
cout<<"============================================================="<<endl;
cout<<"                  TERIMA KASIH";
}
else if((kode=='m')||(kode=='M'))
{
int lamaa;
cout<<"Nama kamar yang di sewa     : Monaco "<<endl;
lamaa = lama * 35000;
cout<<"============================================================="<<endl;
cout<<"Jumlah Biaya                 : "<<lamaa<<endl;
cout<<"============================================================="<<endl;
cout<<"                  TERIMA KASIH";
}
}

Senin, 21 Oktober 2013

Program gambar Hati/Love C++

//---------------------------------------------------------------------------

#pragma hdrstop
#include <conio.h>
#include <iostream.h>
//---------------------------------------------------------------------------
int main()
{
clrscr();
int i,j;
for(i=1;i<=22;i++){
         for(j=1;j<=60;j++){
         if(i==1) if(((j>=14)&&(j<=23))||((j>=39)&&(j<=48))) cout<<"*"; else cout<<" ";
         else if(i==2) if(((j>=11)&&(j<=26))||((j>=36)&&(j<=51))) cout<<"*"; else cout<<" ";
         else if(i==3) if(((j>=9)&&(j<=28))||((j>=34)&&(j<=53))) cout<<"*"; else cout<<" ";
         else if(i==4) if(((j>=7)&&(j<=30))||((j>=32)&&(j<=55))) cout<<"*"; else cout<<" ";
         else if((i>=5)&&(i<=8)) if((j>=5)&&(j<=57)) cout<<"*"; else cout<<" ";
         else if(i==9)  if((j>=7)&&(j<=55))  cout<<"*"; else cout<<" ";
         else if(i==10) if((j>=9)&&(j<=53))  cout<<"*"; else cout<<" ";
         else if(i==11) if((j>=11)&&(j<=51)) cout<<"*"; else cout<<" ";
         else if(i==12) if((j>=13)&&(j<=49)) cout<<"*"; else cout<<" ";
         else if(i==13) if((j>=15)&&(j<=47)) cout<<"*"; else cout<<" ";
         else if(i==14) if((j>=17)&&(j<=45)) cout<<"*"; else cout<<" ";
         else if(i==15) if((j>=19)&&(j<=43)) cout<<"*"; else cout<<" ";
         else if(i==16) if((j>=21)&&(j<=41)) cout<<"*"; else cout<<" ";
         else if(i==17) if((j>=23)&&(j<=39)) cout<<"*"; else cout<<" ";
         else if(i==18) if((j>=25)&&(j<=37)) cout<<"*"; else cout<<" ";
         else if(i==19) if((j>=27)&&(j<=35)) cout<<"*"; else cout<<" ";
         else if(i==20) if((j>=29)&&(j<=33)) cout<<"*"; else cout<<" ";
         else if(i==21) if((j>=30)&&(j<=32)) cout<<"*"; else cout<<" ";
         else if(i==22) if(j==31) cout<<"*"; else cout<<" ";
      }
      cout<<"\n";
   }
   getch();
}

//---------------------------------------------------------------------------

Jumat, 18 Oktober 2013

GAME SEDERHANA C++

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

main()
{
char abc, a, b, c, d, e, f, g, h, i;
atas:
clrscr();
gotoxy(70,1);
cout<<">>>HS-32<<<";
gotoxy(10,2);
cout<<"x   x   ooo";
gotoxy(10,3);
cout<<" x x   o   o";
gotoxy(10,4);
cout<<"  x    o   o";
gotoxy(10,5);
cout<<" x x   o   o";
gotoxy(10,6);
cout<<"x   x   ooo";

gotoxy(58,2);
cout<<"o   o   xxx";
gotoxy(58,3);
cout<<" o o   x   x";
gotoxy(58,4);
cout<<"  o    x   x";
gotoxy(58,5);
cout<<" o o   x   x";
gotoxy(58,6);
cout<<"o   o   xxx";

gotoxy(33,1);
cout<<"-------------";
gotoxy(33,2);
cout<<"| 1 | 2 | 3 |";
gotoxy(33,3);
cout<<"----+---+----";
gotoxy(33,4);
cout<<"| 4 | 5 | 6 |";
gotoxy(33,5);
cout<<"----+---+----";
gotoxy(33,6);
cout<<"| 7 | 8 | 9 |";
gotoxy(33,7);
cout<<"-------------";
gotoxy(1,9);
cout<<"\t\t   Tekan [enter] untuk memulai permainan!";
abc=getche();

if (abc=='1')
{exit(0);}
else
{
cout<<endl<<endl;
cout<<"\t\t\t\t-------------\n";
cout<<"\t\t\t\t|   |   |   |\n";
cout<<"\t\t\t\t----+---+----\n";
cout<<"\t\t\t\t|   |   |   |\n";
cout<<"\t\t\t\t----+---+----\n";
cout<<"\t\t\t\t|   |   |   |\n";
cout<<"\t\t\t\t-------------\n\n";

cout<<" Pilih angka antara 1 sampai 9 : \n";
cout<<"  Player 1 : ";
cin>>a;
if (a=='1')
{gotoxy(35,12);
cout<<"X";}
else if (a=='2')
{gotoxy(39,12);
cout<<"X";}
else if (a=='3')
{gotoxy(43,12);
cout<<"X";}
else if (a=='4')
{gotoxy(35,14);
cout<<"X";}
else if (a=='5')
{gotoxy(39,14);
cout<<"X";}
else if (a=='6')
{gotoxy(43,14);
cout<<"X";}
else if (a=='7')
{gotoxy(35,16);
cout<<"X";}
else if (a=='8')
{gotoxy(39,16);
cout<<"X";}
else
{gotoxy(43,16);
cout<<"X";}

gotoxy(1,21);
cout<<"  Player 2 : ";
cin>>b;
if (b=='1')
{gotoxy(35,12);
cout<<"O";}
else if (b=='2')
{gotoxy(39,12);
cout<<"O";}
else if (b=='3')
{gotoxy(43,12);
cout<<"O";}
else if (b=='4')
{gotoxy(35,14);
cout<<"O";}
else if (b=='5')
{gotoxy(39,14);
cout<<"O";}
else if (b=='6')
{gotoxy(43,14);
cout<<"O";}
else if (b=='7')
{gotoxy(35,16);
cout<<"O";}
else if (b=='8')
{gotoxy(39,16);
cout<<"O";}
else
{gotoxy(43,16);
cout<<"O";}

gotoxy(16,20);
cout<<"  Player 1 : ";
cin>>c;
if (c=='1')
{gotoxy(35,12);
cout<<"X";}
else if (c=='2')
{gotoxy(39,12);
cout<<"X";}
else if (c=='3')
{gotoxy(43,12);
cout<<"X";}
else if (c=='4')
{gotoxy(35,14);
cout<<"X";}
else if (c=='5')
{gotoxy(39,14);
cout<<"X";}
else if (c=='6')
{gotoxy(43,14);
cout<<"X";}
else if (c=='7')
{gotoxy(35,16);
cout<<"X";}
else if (c=='8')
{gotoxy(39,16);
cout<<"X";}
else
{gotoxy(43,16);
cout<<"X";}

gotoxy(16,21);
cout<<"  Player 2 : ";
cin>>d;
if (d=='1')
{gotoxy(35,12);
cout<<"O";}
else if (d=='2')
{gotoxy(39,12);
cout<<"O";}
else if (d=='3')
{gotoxy(43,12);
cout<<"O";}
else if (d=='4')
{gotoxy(35,14);
cout<<"O";}
else if (d=='5')
{gotoxy(39,14);
cout<<"O";}
else if (d=='6')
{gotoxy(43,14);
cout<<"O";}
else if (d=='7')
{gotoxy(35,16);
cout<<"O";}
else if (d=='8')
{gotoxy(39,16);
cout<<"O";}
else
{gotoxy(43,16);
cout<<"O";}

gotoxy(31,20);
cout<<"  Player 1 : ";
cin>>e;
if (e=='1')
{gotoxy(35,12);
cout<<"X";}
else if (e=='2')
{gotoxy(39,12);
cout<<"X";}
else if (e=='3')
{gotoxy(43,12);
cout<<"X";}
else if (e=='4')
{gotoxy(35,14);
cout<<"X";}
else if (e=='5')
{gotoxy(39,14);
cout<<"X";}
else if (e=='6')
{gotoxy(43,14);
cout<<"X";}
else if (e=='7')
{gotoxy(35,16);
cout<<"X";}
else if (e=='8')
{gotoxy(39,16);
cout<<"X";}
else
{gotoxy(43,16);
cout<<"X";}

if (((a=='1' || a=='2' || a=='3') && (c=='1' || c=='2' || c=='3') && (e=='1' || e=='2' || e=='3')) ||
((a=='4' || a=='5' || a=='6') && (c=='4' || c=='5' || c=='6') && (e=='4' || e=='5' || e=='6')) ||
 ((a=='7' || a=='8' || a=='9') && (c=='7' || c=='8' || c=='9') && (e=='7' || e=='8' || e=='9')) ||
((a=='1' || a=='4' || a=='7') && (c=='1' || c=='4' || c=='7') && (e=='1' || e=='4' || e=='7')) ||
 ((a=='2' || a=='5' || a=='8') && (c=='2' || c=='5' || c=='8') && (e=='2' || e=='5' || e=='8')) ||
((a=='3' || a=='6' || a=='9') && (c=='3' || c=='6' || c=='9') && (e=='3' || e=='6' || e=='9')) ||
 ((a=='1' || a=='5' || a=='9') && (c=='1' || c=='5' || c=='9') && (e=='1' || e=='5' || e=='9')) ||
((a=='3' || a=='5' || a=='7') && (c=='3' || c=='5' || c=='7') && (e=='3' || e=='5' || e=='7')))
   {gotoxy(1,23);
   cout<<"\t\t\tPlayer 1 Menang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}
   else
   {
      gotoxy(31,21);
cout<<"  Player 2 : ";
cin>>f;
if (f=='1')
{gotoxy(35,12);
cout<<"O";}
else if (f=='2')
{gotoxy(39,12);
cout<<"O";}
else if (f=='3')
{gotoxy(43,12);
cout<<"O";}
else if (f=='4')
{gotoxy(35,14);
cout<<"O";}
else if (f=='5')
{gotoxy(39,14);
cout<<"O";}
else if (f=='6')
{gotoxy(43,14);
cout<<"O";}
else if (f=='7')
{gotoxy(35,16);
cout<<"O";}
else if (f=='8')
{gotoxy(39,16);
cout<<"O";}
else
{gotoxy(43,16);
cout<<"O";}

if (((b=='1' || b=='2' || b=='3') && (d=='1' || d=='2' || d=='3') && (f=='1' || f=='2' || f=='3')) ||
 ((b=='4' || b=='5' || b=='6') && (d=='4' || d=='5' || d=='6') && (f=='4' || f=='5' || f=='6')) ||
 ((b=='7' || b=='8' || b=='9') && (d=='7' || d=='8' || d=='9') && (f=='7' || f=='8' || f=='9')) ||
((b=='1' || b=='4' || b=='7') && (d=='1' || d=='4' || d=='7') && (f=='1' || f=='4' || f=='7')) ||
 ((b=='2' || b=='5' || b=='8') && (d=='2' || d=='5' || d=='8') && (f=='2' || f=='5' || f=='8')) ||
((b=='3' || b=='6' || b=='9') && (d=='3' || d=='6' || d=='9') && (f=='3' || f=='6' || f=='9')) ||
 ((b=='1' || b=='5' || b=='9') && (d=='1' || d=='5' || d=='9') && (f=='1' || f=='5' || f=='9')) ||
((b=='3' || b=='5' || b=='7') && (d=='3' || d=='5' || d=='7') && (f=='3' || f=='5' || f=='7')))
   {gotoxy(1,23);
   cout<<"\t\t\tPlayer 2 Menang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}
   else
   {
gotoxy(46,20);
cout<<"  Player 1 : ";
cin>>g;
if (g=='1')
{gotoxy(35,12);
cout<<"X";}
else if (g=='2')
{gotoxy(39,12);
cout<<"X";}
else if (g=='3')
{gotoxy(43,12);
cout<<"X";}
else if (g=='4')
{gotoxy(35,14);
cout<<"X";}
else if (g=='5')
{gotoxy(39,14);
cout<<"X";}
else if (g=='6')
{gotoxy(43,14);
cout<<"X";}
else if (g=='7')
{gotoxy(35,16);
cout<<"X";}
else if (g=='8')
{gotoxy(39,16);
cout<<"X";}
else
{gotoxy(43,16);
cout<<"X";}

if (((a=='1' || a=='2' || a=='3') && (c=='1' || c=='2' || c=='3') && (g=='1' || g=='2' || g=='3')) ||
((a=='4' || a=='5' || a=='6') && (c=='4' || c=='5' || c=='6') && (g=='4' || g=='5' || g=='6')) ||
 ((a=='7' || a=='8' || a=='9') && (c=='7' || c=='8' || c=='9') && (g=='7' || g=='8' || g=='9')) ||
((a=='1' || a=='4' || a=='7') && (c=='1' || c=='4' || c=='7') && (g=='1' || g=='4' || g=='7')) ||
((a=='2' || a=='5' || a=='8') && (c=='2' || c=='5' || c=='8') && (g=='2' || g=='5' || g=='8')) ||
((a=='3' || a=='6' || a=='9') && (c=='3' || c=='6' || c=='9') && (g=='3' || g=='6' || g=='9')) ||
((a=='1' || a=='5' || a=='9') && (c=='1' || c=='5' || c=='9') && (g=='1' || g=='5' || g=='9')) ||
((a=='3' || a=='5' || a=='7') && (c=='3' || c=='5' || c=='7') && (g=='3' || g=='5' || g=='7')) ||
((a=='1' || a=='2' || a=='3') && (g=='1' || g=='2' || g=='3') && (e=='1' || e=='2' || e=='3')) ||
((a=='4' || a=='5' || a=='6') && (g=='4' || g=='5' || g=='6') && (e=='4' || e=='5' || e=='6')) ||
((a=='7' || a=='8' || a=='9') && (g=='7' || g=='8' || g=='9') && (e=='7' || e=='8' || e=='9')) ||
((a=='1' || a=='4' || a=='7') && (g=='1' || g=='4' || g=='7') && (e=='1' || e=='4' || e=='7')) ||
((a=='2' || a=='5' || a=='8') && (g=='2' || g=='5' || g=='8') && (e=='2' || e=='5' || e=='8')) ||
((a=='3' || a=='6' || a=='9') && (g=='3' || g=='6' || g=='9') && (e=='3' || e=='6' || e=='9')) ||
((a=='1' || a=='5' || a=='9') && (g=='1' || g=='5' || g=='9') && (e=='1' || e=='5' || e=='9')) ||
((a=='3' || a=='5' || a=='7') && (g=='3' || g=='5' || g=='7') && (e=='3' || e=='5' || e=='7')) ||
((g=='1' || g=='2' || g=='3') && (c=='1' || c=='2' || c=='3') && (e=='1' || e=='2' || e=='3')) ||
((g=='4' || g=='5' || g=='6') && (c=='4' || c=='5' || c=='6') && (e=='4' || e=='5' || e=='6')) ||
 ((g=='7' || g=='8' || g=='9') && (c=='7' || c=='8' || c=='9') && (e=='7' || e=='8' || e=='9')) ||
((g=='1' || g=='4' || g=='7') && (c=='1' || c=='4' || c=='7') && (e=='1' || e=='4' || e=='7')) ||
 ((g=='2' || g=='5' || g=='8') && (c=='2' || c=='5' || c=='8') && (e=='2' || e=='5' || e=='8')) ||
((g=='3' || g=='6' || g=='9') && (c=='3' || c=='6' || c=='9') && (e=='3' || e=='6' || e=='9')) ||
 ((g=='1' || g=='5' || g=='9') && (c=='1' || c=='5' || c=='9') && (e=='1' || e=='5' || e=='9')) ||
((g=='3' || g=='5' || g=='7') && (c=='3' || c=='5' || c=='7') && (e=='3' || e=='5' || e=='7')))
   {gotoxy(1,23);
   cout<<"\t\t\tPlayer 1 Menang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}
else
{
gotoxy(46,21);
cout<<"  Player 2 : ";
cin>>h;
if (h=='1')
{gotoxy(35,12);
cout<<"O";}
else if (h=='2')
{gotoxy(39,12);
cout<<"O";}
else if (h=='3')
{gotoxy(43,12);
cout<<"O";}
else if (h=='4')
{gotoxy(35,14);
cout<<"O";}
else if (h=='5')
{gotoxy(39,14);
cout<<"O";}
else if (h=='6')
{gotoxy(43,14);
cout<<"O";}
else if (h=='7')
{gotoxy(35,16);
cout<<"O";}
else if (h=='8')
{gotoxy(39,16);
cout<<"O";}
else
{gotoxy(43,16);
cout<<"O";}

if (((b=='1' || b=='2' || b=='3') && (d=='1' || d=='2' || d=='3') && (h=='1' || h=='2' || h=='3')) ||
((b=='4' || b=='5' || b=='6') && (d=='4' || d=='5' || d=='6') && (h=='4' || h=='5' || h=='6')) ||
((b=='7' || b=='8' || b=='9') && (d=='7' || d=='8' || d=='9') && (h=='7' || h=='8' || h=='9')) ||
((b=='1' || b=='4' || b=='7') && (d=='1' || d=='4' || d=='7') && (h=='1' || h=='4' || h=='7')) ||
((b=='2' || b=='5' || b=='8') && (d=='2' || d=='5' || d=='8') && (h=='2' || h=='5' || h=='8')) ||
((b=='3' || b=='6' || b=='9') && (d=='3' || d=='6' || d=='9') && (h=='3' || h=='6' || h=='9')) ||
((b=='1' || b=='5' || b=='9') && (d=='1' || d=='5' || d=='9') && (h=='1' || h=='5' || h=='9')) ||
((b=='3' || b=='5' || b=='7') && (d=='3' || d=='5' || d=='7') && (h=='3' || h=='5' || h=='7')) ||
((b=='1' || b=='2' || b=='3') && (h=='1' || h=='2' || h=='3') && (f=='1' || f=='2' || f=='3')) ||
((b=='4' || b=='5' || b=='6') && (h=='4' || h=='5' || h=='6') && (f=='4' || f=='5' || f=='6')) ||
((b=='7' || b=='8' || b=='9') && (h=='7' || h=='8' || h=='9') && (f=='7' || f=='8' || f=='9')) ||
((b=='1' || b=='4' || b=='7') && (h=='1' || h=='4' || h=='7') && (f=='1' || f=='4' || f=='7')) ||
((b=='2' || b=='5' || b=='8') && (h=='2' || h=='5' || h=='8') && (f=='2' || f=='5' || f=='8')) ||
((b=='3' || b=='6' || b=='9') && (h=='3' || h=='6' || h=='9') && (f=='3' || f=='6' || f=='9')) ||
((b=='1' || b=='5' || b=='9') && (h=='1' || h=='5' || h=='9') && (f=='1' || f=='5' || f=='9')) ||
((b=='3' || b=='5' || b=='7') && (h=='3' || h=='5' || h=='7') && (f=='3' || f=='5' || f=='7')) ||
((h=='1' || h=='2' || h=='3') && (d=='1' || d=='2' || d=='3') && (f=='1' || f=='2' || f=='3')) ||
((h=='4' || h=='5' || h=='6') && (d=='4' || d=='5' || d=='6') && (f=='4' || f=='5' || f=='6')) ||
((h=='7' || h=='8' || h=='9') && (d=='7' || d=='8' || d=='9') && (f=='7' || f=='8' || f=='9')) ||
((h=='1' || h=='4' || h=='7') && (d=='1' || d=='4' || d=='7') && (f=='1' || f=='4' || f=='7')) ||
((h=='2' || h=='5' || h=='8') && (d=='2' || d=='5' || d=='8') && (f=='2' || f=='5' || f=='8')) ||
((h=='3' || h=='6' || h=='9') && (d=='3' || d=='6' || d=='9') && (f=='3' || f=='6' || f=='9')) ||
((h=='1' || h=='5' || h=='9') && (d=='1' || d=='5' || d=='9') && (f=='1' || f=='5' || f=='9')) ||
((h=='3' || h=='5' || h=='7') && (d=='3' || d=='5' || d=='7') && (f=='3' || f=='5' || f=='7')))
   {gotoxy(1,23);
   cout<<"\t\t\tPlayer 2 Menang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}
else
{
gotoxy(61,20);
cout<<"  Player 1 : ";
cin>>i;
if (i=='1')
{gotoxy(35,12);
cout<<"X";}
else if (i=='2')
{gotoxy(39,12);
cout<<"X";}
else if (i=='3')
{gotoxy(43,12);
cout<<"X";}
else if (i=='4')
{gotoxy(35,14);
cout<<"X";}
else if (i=='5')
{gotoxy(39,14);
cout<<"X";}
else if (i=='6')
{gotoxy(43,14);
cout<<"X";}
else if (i=='7')
{gotoxy(35,16);
cout<<"X";}
else if (i=='8')
{gotoxy(39,16);
cout<<"X";}
else
{gotoxy(43,16);
cout<<"X";}

if (((a=='1' || a=='2' || a=='3') && (c=='1' || c=='2' || c=='3') && (i=='1' || i=='2' || i=='3')) ||
((a=='4' || a=='5' || a=='6') && (c=='4' || c=='5' || c=='6') && (i=='4' || i=='5' || i=='6')) ||
((a=='7' || a=='8' || a=='9') && (c=='7' || c=='8' || c=='9') && (i=='7' || i=='8' || i=='9')) ||
((a=='1' || a=='4' || a=='7') && (c=='1' || c=='4' || c=='7') && (i=='1' || i=='4' || i=='7')) ||
 ((a=='2' || a=='5' || a=='8') && (c=='2' || c=='5' || c=='8') && (i=='2' || i=='5' || i=='8')) ||
((a=='3' || a=='6' || a=='9') && (c=='3' || c=='6' || c=='9') && (i=='3' || i=='6' || i=='9')) ||
((a=='1' || a=='5' || a=='9') && (c=='1' || c=='5' || c=='9') && (i=='1' || i=='5' || i=='9')) ||
((a=='3' || a=='5' || a=='7') && (c=='3' || c=='5' || c=='7') && (i=='3' || i=='5' || i=='7')) ||
((a=='1' || a=='2' || a=='3') && (i=='1' || i=='2' || i=='3') && (e=='1' || e=='2' || e=='3')) ||
((a=='4' || a=='5' || a=='6') && (i=='4' || i=='5' || i=='6') && (e=='4' || e=='5' || e=='6')) ||
((a=='7' || a=='8' || a=='9') && (i=='7' || i=='8' || i=='9') && (e=='7' || e=='8' || e=='9')) ||
((a=='1' || a=='4' || a=='7') && (i=='1' || i=='4' || i=='7') && (e=='1' || e=='4' || e=='7')) ||
((a=='2' || a=='5' || a=='8') && (i=='2' || i=='5' || i=='8') && (e=='2' || e=='5' || e=='8')) ||
((a=='3' || a=='6' || a=='9') && (i=='3' || i=='6' || i=='9') && (e=='3' || e=='6' || e=='9')) ||
((a=='1' || a=='5' || a=='9') && (i=='1' || i=='5' || i=='9') && (e=='1' || e=='5' || e=='9')) ||
((a=='3' || a=='5' || a=='7') && (i=='3' || i=='5' || i=='7') && (e=='3' || e=='5' || e=='7')) ||
 ((i=='1' || i=='2' || i=='3') && (c=='1' || c=='2' || c=='3') && (e=='1' || e=='2' || e=='3')) ||
((i=='4' || i=='5' || i=='6') && (c=='4' || c=='5' || c=='6') && (e=='4' || e=='5' || e=='6')) ||
 ((i=='7' || i=='8' || i=='9') && (c=='7' || c=='8' || c=='9') && (e=='7' || e=='8' || e=='9')) ||
((i=='1' || i=='4' || i=='7') && (c=='1' || c=='4' || c=='7') && (e=='1' || e=='4' || e=='7')) ||
 ((i=='2' || i=='5' || i=='8') && (c=='2' || c=='5' || c=='8') && (e=='2' || e=='5' || e=='8')) ||
((i=='3' || i=='6' || i=='9') && (c=='3' || c=='6' || c=='9') && (e=='3' || e=='6' || e=='9')) ||
 ((i=='1' || i=='5' || i=='9') && (c=='1' || c=='5' || c=='9') && (e=='1' || e=='5' || e=='9')) ||
((i=='3' || i=='5' || i=='7') && (c=='3' || c=='5' || c=='7') && (e=='3' || e=='5' || e=='7')) ||
 ((g=='1' || g=='2' || g=='3') && (c=='1' || c=='2' || c=='3') && (i=='1' || i=='2' || i=='3')) ||
((g=='4' || g=='5' || g=='6') && (c=='4' || c=='5' || c=='6') && (i=='4' || i=='5' || i=='6')) ||
 ((g=='7' || g=='8' || g=='9') && (c=='7' || c=='8' || c=='9') && (i=='7' || i=='8' || i=='9')) ||
((g=='1' || g=='4' || g=='7') && (c=='1' || c=='4' || c=='7') && (i=='1' || i=='4' || i=='7')) ||
 ((g=='2' || g=='5' || g=='8') && (c=='2' || c=='5' || c=='8') && (i=='2' || i=='5' || i=='8')) ||
((g=='3' || g=='6' || g=='9') && (c=='3' || c=='6' || c=='9') && (i=='3' || i=='6' || i=='9')) ||
 ((g=='1' || g=='5' || g=='9') && (c=='1' || c=='5' || c=='9') && (i=='1' || i=='5' || i=='9')) ||
((g=='3' || g=='5' || g=='7') && (c=='3' || c=='5' || c=='7') && (i=='3' || i=='5' || i=='7')) ||
 ((g=='1' || g=='2' || g=='3') && (i=='1' || i=='2' || i=='3') && (e=='1' || e=='2' || e=='3')) ||
((g=='4' || g=='5' || g=='6') && (i=='4' || i=='5' || i=='6') && (e=='4' || e=='5' || e=='6')) ||
 ((g=='7' || g=='8' || g=='9') && (i=='7' || i=='8' || i=='9') && (e=='7' || e=='8' || e=='9')) ||
((g=='1' || g=='4' || g=='7') && (i=='1' || i=='4' || i=='7') && (e=='1' || e=='4' || e=='7')) ||
 ((g=='2' || g=='5' || g=='8') && (i=='2' || i=='5' || i=='8') && (e=='2' || e=='5' || e=='8')) ||
((g=='3' || g=='6' || g=='9') && (i=='3' || i=='6' || i=='9') && (e=='3' || e=='6' || e=='9')) ||
 ((g=='1' || g=='5' || g=='9') && (i=='1' || i=='5' || i=='9') && (e=='1' || e=='5' || e=='9')) ||
((g=='3' || g=='5' || g=='7') && (i=='3' || i=='5' || i=='7') && (e=='3' || e=='5' || e=='7')) ||
 ((a=='1' || a=='2' || a=='3') && (g=='1' || g=='2' || g=='3') && (i=='1' || i=='2' || i=='3')) ||
((a=='4' || a=='5' || a=='6') && (g=='4' || g=='5' || g=='6') && (i=='4' || i=='5' || i=='6')) ||
 ((a=='7' || a=='8' || a=='9') && (g=='7' || g=='8' || g=='9') && (i=='7' || i=='8' || i=='9')) ||
((a=='1' || a=='4' || a=='7') && (g=='1' || g=='4' || g=='7') && (i=='1' || i=='4' || i=='7')) ||
 ((a=='2' || a=='5' || a=='8') && (g=='2' || g=='5' || g=='8') && (i=='2' || i=='5' || i=='8')) ||
((a=='3' || a=='6' || a=='9') && (g=='3' || g=='6' || g=='9') && (i=='3' || i=='6' || i=='9')) ||
 ((a=='1' || a=='5' || a=='9') && (g=='1' || g=='5' || g=='9') && (i=='1' || i=='5' || i=='9')) ||
((a=='3' || a=='5' || a=='7') && (g=='3' || g=='5' || g=='7') && (i=='3' || i=='5' || i=='7')))

   {gotoxy(1,23);
   cout<<"\t\t\tPlayer 1 Menang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}
   else
   {
   gotoxy(1,23);
   cout<<"\t\t\tPermainan Imbang!!!\n";
   cout<<"Tekan [1] untuk main lagi, dan tekan [2] untuk keluar dari permainan!";
cin>>abc;
if (abc=='1')
{goto atas;}
else
{exit(0);}}}}}}}
getch();
}

KALKULATOR SEDERHAN C++

#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
main()
{
int a, e, f;
char d;
float b, c, hasil;
atas:
clrscr();
cout<<"\t Program Kalkulator Sederhana\n";
cout<<"\t==============================\n\n";

cout<<"  1. Tambah\n";
cout<<"  2. Kurang\n";
cout<<"  3. Kali\n";
cout<<"  4. Bagi\n";
cout<<"  5. Pangkat\n";
cout<<"  6. Akar\n";
cout<<"  7. Sinus\n";
cout<<"  8. Cosinus\n";
cout<<"  9. Tangens\n";
cout<<" 10. Log\n";
cout<<" 11. Modulus\n";
cout<<" 12. Ln\n\n";

cout<<" Pilih Operator : ";
cin>>a;
cout<<endl;
if (a==1)
{
   cout<<" Input Angka Pertama : ";
   cin>>b;
   cout<<" Input Angka Kedua   : ";
   cin>>c;
   hasil=b+c;
   cout<<"\n "<<b<<" + "<<c<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==2)
{
   cout<<" Input Angka Pertama : ";
   cin>>b;
   cout<<" Input Angka Kedua   : ";
   cin>>c;
   hasil=b-c;
   cout<<"\n "<<b<<" - "<<c<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();

   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==3)
{
   cout<<" Input Angka Pertama : ";
   cin>>b;
   cout<<" Input Angka Kedua   : ";
   cin>>c;
   hasil=b*c;
   cout<<"\n "<<b<<" x "<<c<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==4)
{
   cout<<" Input Angka Pertama : ";
   cin>>b;
   cout<<" Input Angka Kedua   : ";
   cin>>c;
   hasil=b/c;
   cout<<"\n "<<b<<" : "<<c<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==5)
{
   cout<<" Input Angka    : ";
   cin>>b;
   cout<<" Input Pangkat  : ";
   cin>>c;
   hasil=pow(b,c);
   cout<<"\n "<<b<<"^"<<c<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==6)
{
   cout<<" Input Angka    : ";
   cin>>b;
   hasil=sqrt(b);
   cout<<"\n Akar "<<b<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==7)
{
   cout<<" Input Sudut    : ";
   cin>>b;
   hasil= sin(b/57.2958);
   cout<<"\n Sin "<<b<<" Derajat = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==8)
{
   cout<<" Input Sudut    : ";
   cin>>b;
   hasil=cos(b/57.2958);
   cout<<"\n Cos "<<b<<" Derajat = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==9)
{
   cout<<" Input Sudut    : ";
   cin>>b;
   hasil=tan(b/57.2958);
   cout<<"\n Tan "<<b<<" Derajat = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==10)
{
   cout<<" Input Angka    : ";
   cin>>b;
   hasil=log10(b);
   cout<<"\n Log "<<b<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==11)
{
   cout<<" Input Angka Pertama : ";
   cin>>e;
   cout<<" Input Angka Kedua   : ";
   cin>>f;
   hasil= e % f;
   cout<<"\n "<<e<<" % "<<f<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan Enter Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }
else if (a==12)
{
   cout<<" Input Angka    : ";
   cin>>b;
   hasil=log(b);
   cout<<"\n Ln "<<b<<" = "<<hasil;
   cout<<"\n\n Apakah Anda Ingin Menghitung Lagi?\n";
   cout<<"   Tekan [Y] Untuk Menghitung Lagi.\n";
   cout<<"   Tekan [T] Untuk Menutup Program.";
   d=getche();
   if (d == 'Y' || d == 'y')
    {
      goto atas;
      }
   else
    {
    exit(0);
      }
   }

   else
{
   goto atas;
   }
getch();
}

Minggu, 13 Oktober 2013

PROGRAM BUBLE SHORT ASCENDING C++

//---------------------------------------------------------------------------

#pragma hdrstop
#include <iostream.h>
//---------------------------------------------------------------------------

#pragma argsused
void main()
{
int A[100];
int c=1,i,j,k,p,x,data,idata;
cout << "Program Buble Short\n";
cout << "=====================\n\n";
cout << "masukan jumlah data(max. 100) : ";
cin >> data;
for (idata=0;idata<data;idata++)
{
cout << "Masukan data ke-" << idata+1 << " : ";
cin >> A[idata];
}

cout << "\nData sebelum di urutkan \n";
for (p=0;p<data;p++)
{
cout << A[p] << " ";
}

// Aval proses sorting
do{
x=0;
for (i=0;i<data-1;i++)
{
if (A[i] > A[i+1])
{
k=A[i];
A[i]=A[i+1];
A[i+1]=k;
x++;
}
}

cout << "\n\nLangkah-"<< c << "\n";
for (int p=0;p<data;p++)
{
cout << A[p] << " ";
}
c++;
}while (x>0);
// akhir proses ascending sorting

cout <<"\n\n";
system("pause");
}