两两配对要试几次
运行下面这段程序:
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
vector<int> a = {13, 15, 17, 23, 24};
int n = 0;
for (int i = 0; i < (int)a.size(); i++)
for (int j = i + 1; j < (int)a.size(); j++)
n++;
cout << n << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)