题解 | #最高分与最低分之差#
最高分与最低分之差
https://www.nowcoder.com/practice/e0e4f81dcd55408a8973f8033bbeb1d2
#include <stdio.h> int main() { int n = 0; int num = 0; while (1 == scanf("%d", &n)) { int min = 101; int max = -1; for (int i = 0; i < n; i++) { // 输入数据 scanf("%d", &num); // 获取最大值和最小值 min = (min < num) ? min : num; max = (max > num) ? max : num; } // 输出数据 printf("%d\n", max - min); } return 0; }