思路:
找最大最小值、求和. 没有什么特别的地方.
#include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int maxn = -10001, minn = 10001, sum = 0; for (int i = 0; i < n; i++) { int x; cin >> x; maxn = max(x, maxn); minn = min(x, minn); sum += x; } cout << maxn << ‘\n‘ << minn << ‘\n‘ << sum << endl; return 0; }
原文:https://www.cnblogs.com/AntonLiu/p/12247043.html