//通过冒泡降序排序 #include <stdio.h> void dif_arr(int* arr,int n) { int i = 0; int j = 0; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - 1 - i; j++) { if (arr[j] < arr[j + 1]) { int tmp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tmp; } } } printf("%d\n",arr[0]-arr[n-1]); } int main() { int n = 0; int arr[100] = { 0 }; int i = 0; scanf("%d",&n); for (i = 0; i < n; i++) { scanf("%d",&arr[i]); } dif_arr(arr,n); return 0; }