题解 | 获取数组最值
#include <iostream> using namespace std; int main() { int arr[6] = { 0 }; int len = sizeof(arr) / sizeof(int); for (int i = 0; i < len; i++) { cin >> arr[i]; } // write your code here...... int min = arr[0], max = arr[0], temp; for (int i = 0; i < len; i++){ if (min > arr[i]){ temp = min; min = arr[i]; arr[i] = min; } if (max < arr[i]){ temp = max; max = arr[i]; arr[i] = max; } } cout << min << " " << max << endl; return 0; }