【发布时间】:2020-11-22 01:14:14
【问题描述】:
我创建了一个向量数组。输入后我必须对它们进行排序,我想我需要使用比较器功能,但我不明白如何使用它。
int main()
{
int n, k;
cin >> n >> k;
vector<long long> times[4];
for (int i = 0; i < n; ++i)
{
ll t, a, b;
cin >> t >> a >> b;
times[a * 2 + b].push_back(t);
}
cout << times[0].size();
***//i need to sort the whole of times[0] after this***
}
【问题讨论】:
-
std::sort 是你想要的。看一下,有不清楚的时候再回来。
-
向量已经有一个
<,你不需要自定义比较器,除非你想要自定义比较(即不同于字典顺序的东西) -
向量数组或数组向量。根本不是一回事。
标签: c++ arrays sorting vector stdvector