编程语言单选难度 3真题改编 · 2024
2907. 实现一个函数,检查一个整数数组是否包含重复元素实现一个函数,检查一个整数数组是否包含重复元素。
#include <stdio.h>
#include <stdbool.h>
bool containsDuplicate(int* nums, int size)
{
for (int i = 0; i < size - 1; i++)
{
for (int j = i + 1; j < size; j++)
{
if (____) // 填空
{
return true;
}
}
}
return false;
}
int main()
{
int nums[] = {1, 2, 3, 4, 5, 3};
int size = sizeof(nums) / sizeof(nums[0]);
printf("%d\n", containsDuplicate(nums, size));
return 0;
}
补充代码为:
练习本题 ›
编程语言单选难度 3真题改编 · 2023
2936. 以下 C++ 程序的输出结果的是()
#include <iostream>
#include <map>
#include <memory>
int main(int argc, const char * argv[]) {
std::map<int, std::shared_ptr<int>> map;
std::shared_ptr<int> value1 = std::make_shared<int>(1);
map[1] = value1;
std::shared_ptr<int> value2 = std::make_shared<int>(2);
value1.swap(value2);
printf("%d\n", *value1);
printf("%d\n", *value2);
auto value3 = map[1];
printf("%d\n", *value3);
return 0;
}
练习本题 ›