题解 | 求最大最小数 不用排序,只用返回最大最小值
求最大最小数
https://www.nowcoder.com/practice/82e5ff335eeb486aab359767895cc7b4
#include <iostream> #include <bits/stdc++.h> // INT_MAX / INT_MIN 库 using namespace std; int main() { int n, temp; while (cin >> n) { int max = INT_MIN; int min = INT_MAX; while (n--) { cin >> temp; if (temp > max) max = temp; if (temp < min) min = temp; } cout << max << " " << min << endl; } }#考研##复试练习#
2025考研复试 文章被收录于专栏
复试ing,努力中。。。