用C语言写一个函数,用冒泡法对输入的10个字符按由小到大的顺序排列

来源:百度知道 编辑:UC知道 时间:2024/05/17 18:54:58
写一个函数,用冒泡法对输入的10个字符按由小到大的顺序排列
把这个题目的全部过程写出来,要能在软件上面运行出来的啊.谢谢大家了哦

maopao(int a[],int num)
{
int i,j,temp;
printf("\nmao pao pai xu\n");
for(i=0;i<=num;i++)
for(j=0;j<=num-1;j++)
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
其接受的实参为一个数组和这个数组元素个数。

全过程
#include<stdio.h>
void main()
{
char c;int x; int a[100];
int i=0,j,num,temp;
clrscr();
printf("please some integers:\n");
scanf("%d", &x);
c=getchar();
while(c!='#')
{ a[i]=x;
scanf("%d", &x);
c=getchar();
i++;
num=i-1;
}
if(num==0)
{
printf("\nYou should give at least two integers!");
exit(0);
}
printf("The integers you input:\n");
for(i=0;i<=num;i++)
{printf("%-5d",a[i]);
if(i%5==4) printf("\n&quo