標(biāo)題:
靜態(tài)冒泡排序
[打印本頁(yè)]
作者:
顧笑傾城
時(shí)間:
2018-3-13 23:35
標(biāo)題:
靜態(tài)冒泡排序
# include <stdio.h>
int fun(int a[])
{
int i = 0;
int j = 0;
int temp = 0;
for (i = 0; i < 5; i++)
{
for (j = 0; j < 5-i-1; j++)
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for (i=0;i<5;i++)
{
printf("%d ", a[i]);
}
return 0;
}
int main()
{
int a[] = { 18,12,3,15,7 };
fun(a);
system("pause");
return 0;
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1