这段步骤走完得到谁
一套很短的步骤:从头扫一遍,记下最大的那个。运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<int> A = {17, 24, 15, 13, 23};
int best = A[0];
for (int x : A) {
if (x > best) best = x;
}
cout << best << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)