算法与数据结构递归单选难度 3真题改编 · 2024
1467. 已知一个有序表(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16),当进行在中间值位置向下取整的二分查找值为0的元素时,查找成功的比较次数为( )
练习本题 ›
编程语言单选难度 3真题改编 · 2024
1474. 下面 C++ 程序的运行结果为()
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
return a.second < b.second;
}
int main() {
std::vector<std::pair<int, int>> v_p;
v_p.emplace_back(1, 2);
v_p.emplace_back(2, 1);
v_p.emplace_back(3, 4);
v_p.emplace_back(4, 3);
sort(v_p.begin(), v_p.end(), cmp);
for (auto t : v_p)
{
std::cout << t.first << " " << t.second << std::endl;
}
return 0;
}
练习本题 ›