题目要求
代码块
#include <stdio.h>
int main() {
int n;
int buf[100];
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%d", &buf[i]);
}
//冒泡排序主体
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n-i-1; j++)
{
if (buf[j] > buf[j+1])
{
int tmp = buf[j + 1];
buf[j + 1] = buf[j];
buf[j] = tmp;
}
}
}
//输出数组
for (int i = 0; i < n; i++)
{
printf("%d ", buf[i]);
}
printf("\\n");
}
return 0;
}