BUPT-homework/pset4/1-question.c
2021-10-19 22:58:02 +08:00

28 lines
404 B
C

#include <stdio.h>
int main(void) {
// Initialize variables
int n, temp;
scanf("%d", &n);
scanf("%d", &temp);
int min = temp, max = temp, sum = 0;
sum += temp;
for (int i = 0; i < n - 1; i++) {
scanf("%d", &temp);
sum += temp;
if (temp < min) {
min = temp;
}
if (temp > max) {
max = temp;
}
}
printf("%d %d %d\n", sum, max, min);
return 0;
}