RVBTCC/test/sort.c
2024-12-07 14:13:34 +08:00

28 lines
548 B
C

int printf(char* format, ...);
int scanf(char* format, ...);
void sort(int a[], int n) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (a[i] > a[j]) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
}
int main() {
int n;
int a[100];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, n);
for (int i = 0; i < n; i++) {
printf("%d ", a[i]);
}
printf("\n");
}