Friday, 25 May 2012

Bubble Sort Program (class) of the Generated Raptor

#include <iostream>
#include <string>

using namespace std;

class bublesort{
//friend istream& operator>>(istream& in,buble& a);
//friend ostream& operator<<(ostream& out,buble& a);
public:
void buble (int data[100],int_Variable banyak);
void tukar (
int a,
int b)
};
void bublesort::buble (int data[100],int_Variable banyak)
{

int j;
int k;


j =1;
while (!(j>banyak))
{
k =j+1;
while (!(k>banyak))
{
if (data(j)>data(k))
{
tukar(data(j),data(k));
}
else
{
}
k =k+1;
}
j =j+1;
}
}
void tukar (
int a,
int b)
{
int temp;

temp =a;
a =b;
b =temp;
}
int main()
{
string raptor_prompt_variable_zzyz;
int banyak;
int i;

bublesort a ;
raptor_prompt_variable_zzyz ="input banyaknya data";
cout << raptor_prompt_variable_zzyz << endl;
cin >> banyak;
i =1;
while (!(i>banyak))
{
raptor_prompt_variable_zzyz ="inputkan data";
cout << raptor_prompt_variable_zzyz << endl;
cin >> data(i);
cout << "data:"+data(i) << endl;
i =i+1;
}
a.buble(data,banyak);
i =1;
while (!(i>banyak))
{
cout << "isi data:"+data(i) << endl;
i =i+1;
}

system("pause");
return 0;
}

0 comments:

Post a Comment

.

.

.

.
Design by BlogSpotDesign | Ngetik Dot Com