Link's

Blog Liken
Computer and Programer C#

M Abrar Istiadi
Blog-Blogan

Blog Mas Isnan

blog Alif Urashima Keitaro
Hanya Catatan Kecil

Arief Blog
Blog mas Arief

Projecteuler
A series of challenging mathematical/computer programming problems

geeks.netindonesia.net
Geeks Portal adalah sebuah portal komunitas developer Indonesia khususnya .NET Developer

Microsoft DreamSpark
Program Microsoft yang mendukung para pelajar untuk belajar dan mendapatkan software gratis untuk pendidikan

Ilmu Komputer IPB

IPB Badge

IPB

IPB Badge

Counter

mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter

Who's Online

We have 3 guests online
BubleSort PDF Print E-mail
Written by abdulqiflisangadji   
Thursday, 10 December 2009 14:58

Program Ini bertujuan untuk menampilkan urutan angka yang di inputkan dari user secara acak sebanyak jumlah data (n) = 10.

kita menggunakan fungsi void BubbleSort.

#include <stdio.h>
void bubbleSort(int numbers[], int array_size)
{   
int i, j, temp;
for (i = (array_size - 1); i >= 0; i--)
{
for (j = 1; j <= i; j++)
{
if (numbers[j-1] > numbers[j])
{
temp = numbers[j-1];
numbers[j-1] = numbers[j];
numbers[j] = temp;
}
}
}
}

main ()
{
int x[10];
int i;
for(i=0; i<10; i++){
scanf("%d", &x[i]);


}

bubbleSort(x, 10);
for(i=0; i<10; i++){
printf("%d,", x[i]);


}
return 0;
}

Contoh Input : 1 7 3 6 4 3 10 2 5 8

output : 1, 2, 3, 3, 4, 5, 6, 7, 8, 10,

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Last Updated on Monday, 15 February 2010 18:14