#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
main()
{
char huruf[10];
char temp;
int pil[10],n,i,a,tukar;
cout<<"Program Sorting Huruf\n";
cout<<"------------------------------------\n";
cout<<"1.Input Data\n";
cout<<"2.Bubble Sort\n";
cout<<"3.Tampil Data\n";
cout<<"4.Acak Data\n";
cout<<"5.Exit\n";
for(a=0;a<10;a++)
{
cout<<"Pilihan Anda : ";cin>>pil[a];
clrscr();
if(pil[a]==1)
{
cout<<"Masukan Jumlah Data : ";cin>>n;
for(i=0;i<n;i++)
{
cout<<"Input Huruf - "<<(i+1)<<" : ";cin>>huruf[i];
}
cout<<endl;
cout<"Inputkan Data Selesai\n";
clrscr();
}
else if(pil[a]==2)
{
tukar=1;
while(tukar==1)
{
tukar=0;
for(i=0;i<n-1;i++)
{
if(huruf[i]>huruf[i+1])
{
temp=huruf[i];
huruf[i]=huruf[i+1];
huruf[i+1]=temp;
tukar=1;
}
}
}
cout<<"Bubble Sorting Selesai\n";
clrscr();
}
else if(pil[a]==3)
{
for(i=0;i<n;i++)
{
cout<<"Huruf : "<<huruf[i];
}
cout<<endl;
clrscr();
}
else if(pil[a]==4)
{
tukar=1;
while(tukar==1)
{
tukar=0;
for(i=0;i<n-1;i++)
{
if(huruf[i]<huruf[i+1])
{
temp=huruf[i];
huruf[i]=huruf[i+1];
huruf[i+1]=temp;
tukar=1;
}
}
}
cout<<"Bubble Sorting Selesai\n";
clrscr();
}
else if(pil[a]==5)
{
exit(1);
}
}
getch();
}
Subscribe to:
Post Comments (Atom)
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++ #include<stdlib.h> #include<conio.h> #include<iostream.h> struc...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> struct pa...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <iomanip.h> #include...
-
#include <iostream.h> #include <iomanip.h> #include <stdio.h> #include <conio.h> void coba(); struct rumahsakit { ...
No comments:
Post a Comment