发布网友 发布时间:2024-10-23 16:46
共2个回答
热心网友 时间:2024-11-13 21:39
#include <stdio.h>
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[10] = {95, 45, 15, 78, 84, 51, 24, 12, 38, 97};
int i,SIZE=10;
bubble_sort(number, SIZE);
for (i = 0; i < SIZE; i++)
printf("%d", number[i]);
printf("\n");
return 0;
}
热心网友 时间:2024-11-13 21:39
//冒泡排序函数(从高到低)
void bubble_sort(int a[], int n)
{
int i,j;
int tmp;
for(j<0;j<n-1;j++)
for(i=0;i<n-1-j;i++)
if(a[i] < a[i+1])
{
tmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
}
}
热心网友 时间:2024-11-13 21:40
#include <stdio.h>
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[10] = {95, 45, 15, 78, 84, 51, 24, 12, 38, 97};
int i,SIZE=10;
bubble_sort(number, SIZE);
for (i = 0; i < SIZE; i++)
printf("%d", number[i]);
printf("\n");
return 0;
}
热心网友 时间:2024-11-13 21:41
//冒泡排序函数(从高到低)
void bubble_sort(int a[], int n)
{
int i,j;
int tmp;
for(j<0;j<n-1;j++)
for(i=0;i<n-1-j;i++)
if(a[i] < a[i+1])
{
tmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
}
}