Fungsi (mengurutkan angka)
{menginputkan, memproses, mencetak hasil}
Deklarasi
minim, mini, temp ,banyak : integer
i, j , k : integer
data[i] : char
Deskripsi
j =1;
while (!(j>banyak))
{
minim =j;
mini =data(j);
k =j+1;
while (!(k>banyak))
{
if (mini>data(k))
{
minim =k;
mini =data(k);
}
else
{
}
k =k+1;
}
temp =data(j);
data[j] = data(minim);
data[minim] = temp;
j =j+1;
}
C++
#include <iostream>
#include <string>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int minim;
int i;
int mini;
int temp;
int banyak;
int j;
int k;
char data[i] =data[i+1];
raptor_prompt_variable_zzyz ="input banyak data";
cout << raptor_prompt_variable_zzyz << endl;
cin >> banyak;
i =1;
while (!(i>banyak))
{
raptor_prompt_variable_zzyz ="input data";
cout << raptor_prompt_variable_zzyz << endl;
cin >> data(i);
cout << "isi data:"+data(i) << endl; i =i+1;
}
j =1;
while (!(j>banyak))
{
minim =j;
mini =data(j);
k =j+1;
while (!(k>banyak))
{
if (mini>data(k))
{
minim =k;
mini =data(k);
}
else
{
}
k =k+1;
}
temp =data(j);
data[j] = data(minim);
data[minim] = temp;
j =j+1;
}
i =1;
while (!(i>banyak))
{
cout << "isi data:"+data(i) << endl; i =i+1;
}
return 0;
}
Raptor
0 komentar:
Posting Komentar