You are on page 1of 3

Nama: Fatimah Azzahro

Npm: 22410002

#include <iostream>

using namespace std;

int main () {

int i, j, temp, data [6]= {4, 7, 1, 2, 9,5};

cout<<"Data Sebelum di sorting: ";

for(i=0; i<6; i++) {

cout<<data[i]<<" ";

cout<<endl;

//Bubble Sort

for(i=0; i<6; i++) {

for(j=0; j<6-1; j++) {

if (data[j+1] < data[j]) {

temp=data[j];

data[j]=data[j+1];

data[j+1]=temp;

cout<<endl<<" Step Ke "<<i+1<<" : ";

for(int k=0; k<6; k++) {

cout<<data[k]<<" ";

cout<<endl;

// Ending Bubble sort


cout<<"Data Setelah Di Sorting: ";

for (i=0; i<6; i++) {

cout<<data[i]<<" ";

} cout<<endl;

You might also like