berdasarkan request salah seorang pembaca, kali ini saya postingkan bubble sort dengan data yang diinputkan.
selamat mencoba ^_^.
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main ()
{
clrscr();
int arr[100];
int a,x,z;
printf ("\n PROGRAM BUBBLE SORTING \n");
printf("*---**----*--*----***-----****---*---**----*--*---**----*------*\n\n\n");
printf("Data Sebelum di-Sort\n");
printf("----------------------------------------------------\n");
for(a=1;a<=10;a++)
{cout<<"Data ke-"<<a<<"=";
cin>>arr[a];}
for (a=1;a<=10;a++)
{
for (x=1;x<=10-a;x++)
{
if (arr[x]>arr[x+1])
{
z=arr[x];
arr[x]=arr[x+1];
arr[x+1]=z;
}
}
}
printf("\n\n\n\n\nData Setelah di-Sort\n");
printf("====================================================\n");
for (a=1;a<=10;a++)
{printf (" [%d] ", arr[a]);}
printf("\n====================================================\n\n\n\n");
printf(" Composed By :JAYARI/ 10540040\n");
printf(" Terimakasih>>>>>>>\n\n");
printf("Press Anykey to Exit!!");
getch();
}
abcdefghijklmnopqrstuvwxyz
ReplyDelete*_*
ReplyDelete