数组元素排序,冒泡排列,升序
//从键盘输入n (1<=n<=10) 个整数,冒泡 升序排列// #include
#define SIZE 10
void printee (int a[],int n);
void BubbleSort (int a[],int n);
int main()
{
int array[SIZE],n;
int i=0;
do
{printf("Please input n (1<=n<=%d):\n",SIZE); scanf("%d",&n);
}while(n<1||n>SIZE);//保证读入的n 满足条件//
printf("Please input %d elements :\n",n);
for(i=0;i
scanf("%d",&array[i]);//读入数组 array //
BubbleSort(array,n);
printee(array,n);
return 0;
}
void printee (int a[],int n)
{
int i;
printf("The array is :\n");
for(i=0;i
printf("%5d",a[i]);
printf("\n");
}
void BubbleSort (int a[],int n)
{
int i,j,temp;
for(i=0;i
for(j=n-1;j>i;j--)
{
if(a[j]
{