/* prog9_17, 氣泡排序法 */
/* prog9_17, 氣泡排序法 */
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
int main(void)
{
int a[20],i,j,temp,x,y;
srand(time(NULL));
for(i=0;i<20;i++)
{
a[i]=rand()%33+65;
}
for(i=1;i<20;i++)
{
for(j=0;j<(20-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for(x=0;x<20;x++)
{
printf(" %d",a[x]);
}
printf("\n");
}
for(i=0;i<20;i++)
{
printf(" %d",a[i]);
}
system("pause");
return 0;
}
Today's Visitors: 0 Total Visitors: 24
歷史上的今天:

Sealed (Aug 24)
1樓
1樓搶頭香
請問你會打這個程式嗎?
利用氣泡排序法(Bubble Sort)作下列兩組數字的排列(由小到大),並輸出每
一次排
序後的結果
a. 12,26,31,5,11,24,40,6
b. 19,37,17,41,47,31,13,5
因為我之前都沒學過Dev C++ 但是老師要我們交這個作業
你會嗎? 會的話 可以麻煩幫一下嘛?
可以的話 可以+我的即時:aidike2009@yahoo.com.tw
(悄悄話)
哈哈!
那是我的作業!
你的作業應該自己練習!
別像我
C語言被盪!
Only friends can post a comment, Login first