编写一个程序,用起泡法对输入的十个字符由小到大排序
/* Note:Your choice is C IDE */
#include "stdio.h"
//冒泡排序
void choose(int a[10]){
int i,j,temp;
for(i=1;i<10;i++)
{
for(j=9;j>=i;j--)
{
if(a[j]<a[j-1]){
temp=a[j];
a[j]=a[j-1];
a[j-1]=temp;
}
}
}
}
//输出
void output(int a[10]){
int i;
for(i=0;i<10;i++)
printf("%d\t",a[i]);
}
void main()
{
int b[20];
int a[10];
int i,cnt=0;
for(i=0;i<20;i++){
scanf("%d",&b[i]);
if(i%2==0){
a[cnt++]=b[i];
}
}
//冒泡排序
choose(a);
//输出
output(a);
}