#include <iostream> using namespace std; int compare(const void*a, const void *b) { return *(int*)a - *(int*)b; } int main() { int n; cin >> n; int *a = (int*)malloc(n*sizeof(int)); for (int i = 0; i < n; i++){ cin >> a[i]; } qsort(a, n, sizeof(int), compare); cout << a[0]; for (int i = 1; i < n; i++){ cout << ‘ ‘ << a[i]; } }
时间: 2024-10-12 22:03:09