题解 | #最高分与最低分之差#
最高分与最低分之差
https://www.nowcoder.com/practice/e0e4f81dcd55408a8973f8033bbeb1d2
#include <stdio.h> int main() { int max = 0;//最大值 int min = 0;//最小值 int n = 0;//要输入的数的个数 int i = 0; int arr[1000] = { 0 }; scanf("%d", &n); for (i = 0; i <n; i++) { scanf("%d", &arr[i]); } max = arr[0]; min = arr[0]; for (i = 0; i < n; i++) { if (max < arr[i]) { max = arr[i]; } if (min > arr[i]) { min = arr[i]; } } printf("%d", (max - min)); return 0; }