问题:
Write a program that reads in five integers
and then determines and prints the largest and the smallest integers in the group.
#include<stdio.h>
#include<stdlib.h>
int main(void) {
int num;
int min, max;
printf("Input 5 integers:");
for (int i = 0; i < 5; i++) {
scanf_s("%d", &num);
if (i == 0) {
max = num;
min = num;
}
else {
if (num > max) max = num;
if (num < min) min = num;
}
}
printf("The largest value is %d\nThe smallest value is %d\n", max,min);
system("pause");
return 0;
}