题解 | #最高分与最低分之差#
最高分与最低分之差
http://www.nowcoder.com/practice/e0e4f81dcd55408a8973f8033bbeb1d2
int main() {
int n;
scanf("%d", &n);
int m[n];
for (int i = 0; i < n; i++) {
scanf("%d ", &m[i]);
}
int max = m[0], min = m[0];
for (int j = 0; j < n; j++) {
if (m[j] > max) max = m[j];
if (m[j] < min) min = m[j];
}
printf("%d", max - min);
return 0;
}