您的位置:首页 > 其它

rewrw

2015-12-13 10:16 323 查看
#include <stdio.h>

#define SIZE 8


void
bubble_sort(
int
a[],
int
n);


void
bubble_sort(
int
a[],
int
n)

{

int
i, j, temp;

for
(j = 0; j < n - 1; j++)

for
(i = 0; i < n - 1 - j; i++)

{

if
(a[i] > a[i + 1])

{

temp = a[i];

a[i] = a[i + 1];

a[i + 1] = temp;

}

}

}


int
main()

{

int
number[SIZE] = {95, 45, 15, 78, 84, 51, 24, 12};

int
i;

bubble_sort(number, SIZE);

for
(i = 0; i < SIZE; i++)

{

printf
(
"%d"
, number[i]);

}

printf
(
"\n"
);

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: