#include<stdio.h> #include<stdlib.h> int main() { int arr[10] = {0}; int i = 0; int min = 0; int max = 0; for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) { scanf_s("%d", &arr[i]); } max = arr[0]; min = arr[0]; for (i =0; i < sizeof(arr) / sizeof(arr[0]); i++) { if (max < arr[i]) max = arr[i]; if (min>arr[i]) min = arr[i]; } printf("max=%d\n", max); printf("min=%d\n", min); system("pause"); return 0; }
结果:
1 2 3 4 5 6 7 8 9 10
max=10
min=1
请按任意键继续. . .