#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int arr[10];
printf("请输入一串数字:\n");
for (int i = 0; i < 10; i++)
{
scanf("%d",&arr[i]);
}
for (int i = 0; i < 10; i++)//循环次数等于元素
{
for (int j = 0; j < 9 - i; j++)//循环次数等于减去每次外围进行一次
{
if (arr[j] > arr[j + 1])
{
int tmp = arr[j+1];
arr[j+1] = arr[j];
arr[j] = tmp;
}
}
}
for (int i = 0; i < 10; i++)
{
printf("%d ", arr[i]);
}
return 0;
}
标签:tmp,10,arr,int,整数,由小到大,++,printf,排序
From: https://blog.51cto.com/u_16425777/8946922