#include<stdio.h>
int main(){ int a[10]; //冒泡法
int i,j, t;
printf("输入十个数:\n");
for (i = 0; i < 10; i++)
scanf("%d", &a[i]);
printf("\n");
for(j=0;j<9;j++)
for(i=0;i<9;i++)
if (a[i] > a[i + 1]) {
t = a[i]; a[i] = a[i + 1]; a[i + 1] = t;
}
printf(" the soreted numbers:\n");
for (i = 0; i < 10; i++)
printf(" %d" , a[i]);
printf("\n");
return 0;
}
#include<stdio.h> //桶排序
int main(){
int a[101], n, j, t, i;
scanf("%d", &n);//读入n
for (i = 1; i <= n; i++)//循环读入n个图书的ibsn号
{
scanf("%d", &a[i]);
}
for (i = 1; i <= n - 1; i++) {
for (j = 1; j <= n - 1; j++) {
if (a[i] > a[j]) {
t = a[i]; a[i] = a[i + 1]; a[i + 1] = t;
}
}
}
printf("%d", a[1]);//输出第一个数
for (i = 2; i <= n; i++)
{
if (a[i] != a[i - 1])
printf("%d", a[i]);
}
getchar(); getchar();
}