void fun(int a[],int n)
{
int temp;
int i, j;
for (i = 0; i < n - 1; i++)
{
for (j = 0; j
if(a[j] < a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
#include
#define N 10
void bubble(int a[]) {
int i,j,t;
for (i = 1; i <= N-1; i++)
for (j = 0; j <= N-i-1; j++)
if (a[j] < a[j+1])
{t = a[j];a[j] = a[j+1];a[j+1] = t;}
printf("\n排序后的数据为:\n");
for (i = 0; i < N; i++)
printf("%d ", a[i]);
printf("\n");
}
int main() {
int i,a[N];
printf("输入10个数:\n");
for (i=0;i
printf("\n");
bubble(a);
return 0;
}
#include
#define N 20
void fun(int a[],int n)
{
int i,j,t;
for(i=0;i
for(j=0;j
if(a[j+1] {
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
}
void main()
{
int a[N]={11,32,-5,2,14},i,m=5;
printf("排序前的数据:");
for(i=0;i
printf("\n");
fun(a,m);
printf("排序后的顺序:");
for(i=0;i
printf("\n");
}
int temp;
for(int i=0;i
for(int j=i;j
if(a[i] {
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
这是函数中要加入的部分!!希望多多加分,谢谢!