题解 | #争夺前五名#
争夺前五名
https://www.nowcoder.com/practice/cd052308a1c44a88ad00255f312c3e14
#include<stdio.h> int main() { int arr[100]; int a, t; int i, j; scanf("%d",&a); for (i = 0; i < a; i++) { scanf("%d", &arr[i]); } for (i = 0; i < a-1; i++) { for (j = 0; j < a-1 - i; j++) { if (arr[j] < arr[j + 1]) { t = arr[j]; arr[j] = arr[j+1]; arr[j+1] = t; } } } for (i = 0; i < 5; i++) { if(arr[i]==0) { printf("%d",arr[i]); printf(" "); } printf("%d", arr[i]); printf(" "); } return 0; }