This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Kamis, 28 Maret 2013

Program Antrian Pelanggan



#include <cstdlib>
#include <iostream>

using namespace std;

struct pelanggan{
int id, t;
};
void PenjadwalanPelanggan(int n, pelanggan p[]) { 
int i, temp;   
for(i=0; i<n; i++) {
cout<<"Masukan Waktu Pelanggan "<<i+1<< ":";
p[i].id=i+1;
cin>>p[i].t;
    }   
for(i=0; i<n; i++) {
for(int x=0; x<n; x++) {
if(p[x].t>p[x+1].t) {
temp=p[x].t;
p[x].t=p[x+1].t;
p[x+1].t=temp;

temp=p[x].id;
p[x].id=p[x+1].id;
p[x+1].id=temp;                }
        }    }   
cout<<endl;   
cout<<"Urutan Yang dilayani:"<<endl;
for(i=0; i<n; i++) {
cout<<"Pelangan "<<p[i].id;
cout<<endl;
    }   
cout<<endl<<endl;          
}
int main(int argc, char *argv[])
{    int x;
pelanggan y[100];   
cout<<"Masukan Jumlah Pelanggan:";
cin>>x;
    PenjadwalanPelanggan(x, y);   
system("PAUSE");
return EXIT_SUCCESS;
}


Program Matriks C++



#include <cstdlib>
#include <iostream>

using namespace std;

void baca(int q[10][10], int k, int b)
{
for(int w=0;w<k;w++)
for(int e=0;e<b;e++)
     {             cout<<"Data["<<w+1<<","<<e+1<<"]:";
cin>>q[w][e];
     }}
void cetak(int r[10][10], int k, int b)
{
for(int t=0;t<k;t++)
{
for(int y=0;y<k;y++)   
cout<<" "<<r[t][y];
cout<<endl;
}
}void jumlah(int h[10][10],int g[10][10] ,int k,int b,int f[10][10])
{
for(int i=0;i<k;i++)
for(int u=0;u<b;u++)
f[i][u]=h[i][u]+g[i][u];
}
void kali(int h[10][10],int g[10][10] ,int k,int b,int f[10][10])
{     for(int i=0;i<k;i++)
     for(int u=0;u<b;u++)
     f[i][u]=h[i][u]*g[i][u];
}

int main(int argc, char *argv[])
{  int a,b;
int c[10][10],l[10][10];
int j[10][10];
cout<<"Masukan Kolom:";
cin>>a;
cout<<"Masukan baris:";
cin>>b;
cout<<"Pertama"<<endl;
baca(c,a,b);
cetak(c,a,b);
cout<<"Kedua"<<endl;
baca(l,a,b);
cetak(l,a,b);
cout<<endl;
cout<<"Jumlah"<<endl;
jumlah(c,l,a,b,j);
cetak(j,a,b);
cout<<endl;
cout<<"kali"<<endl;
kali(c,l,a,b,j);
cetak(j,a,b);
system("PAUSE");
return EXIT_SUCCESS;
}


Program Binary Search




#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#pragma hdrstop
#pragma argused

using namespace std;

int main(int argc, char *argv[])
{
int a;
int X,i,j,k,p;
int L[10] = a;
cout<<"Masukkan Data"<<a;
if(L[0]<L[9]){
printf("Data Terurut Menaik \n");
        p=0;
        }
else{
printf("Data Terurut Menurun \n");
             p=1;
             }

printf("Data yang akan dicari =");
scanf("%d", &X);
    i=0;
    j=9;
do{
        k=(i+j)/2;
if(p==0){
if(L[k]==X){
printf("Data ditemukan diElemen %d",k);
getch();
return 0;
                             }
else if (L[k]<X){
                                  i=k;     }   else{    j=k;    }    }
else{        if(L[k]==X){                         printf("Data diTemukan dieleme %d",k);
getch();
return 0;
                         }
else if(L[k]>X){
                  i=k;
                  }        else{     j=k;      }
             }}
while(k!=0);
printf("Data Tidak diTemukan");
system("PAUSE");
return EXIT_SUCCESS;
}