题解 | 争夺前五名
#include<stdio.h> int main(void) { int n; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { int temp; temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } for (int i = n - 1; i >= n - 5; i--) { printf("%d ", a[i]); } return 0; }