Bubble Sort (Rinaldi Munir)
#include <stdio.h>
int main()
{
int arr[6] = {25,27,10,8,76,21};
int i,k,temp;
for(i=0;i<6;i++)
{
for(k = 5 ;k>=i+1;k--)
{
if(arr[k] < arr[k-1])
{
temp = arr[k];
arr[k] = arr[k-1];
arr[k-1] = temp;
}
}
}
for(i=0;i<6;i++)
{
printf("%d ",arr[i]);
}
return 0;
}
Komentar
Posting Komentar