#include<stdio.h>
int main()
{
int i,j,tmp;
int a[10] = {
34,13,35,654,35,564,78,54,90,65};//给定一个大小为10的数组用来存放十个数据
for(i = 0;i<9;i++)//用来遍历这十个数据
{
for(j = 0;j<9-i;j++)//每个数需要交换的次数
{
if(a[j]>a[j+1])
{
tmp = a[j];
a[j] = a[j+1];
a[j+1] = tmp;
}
}
}
for(i=0;i<10;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return 0;
}
输出结果