/*This is a test*/
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<string.h>
void main()
{
int num[10], min,temp;
scanf("%d %d %d %d %d %d %d %d %d %d", &num[0], &num[1], &num[2], &num[3], &num[4], &num[5], &num[6], &num[7], &num[8], &num[9]);
for (int i = 0; i <= 9; i++) {
min = i;
for (int j = i+1; j <= 9; j++) {
if (num[j] < num[min])
min = j;
}temp = num[i];
num[i] = num[min];
num[min] = temp;
}for (int k = 0; k <= 9; k++) {
printf("%d,", num[k]);
if (k == 9) printf("\b");
}
}
C-冒泡排序
最新推荐文章于 2023-11-16 12:48:48 发布