GESP C++ 真题 · 逐题精解
首页C++五级真题 › 2024年3月 › 第15题

GESP 2024年3月 C++五级 单选题 第15题

C++五级单选题2024年3月第15题

所属知识点:链表 难度要求:掌握 考频:—

假设给定链表为: ,若调用 searchValue(head, 5) ,函数返回值为( )。
int searchValue(ListNode* head, int target) {
while (head != nullptr) {
if (head->val == target) {
return 1;
}
head = head->next;
}
return 0;
}

正确答案:A

题目解析

链表中存在值为 5 的节点,searchValue 找到后返回 1,选 A。……

完整解析为会员内容二级及以上的逐题精讲需开通 VIP。一级解析全部免费。前往 GESPPASS 解锁

想系统刷完 GESP C++ 1~8 级真题,并查看每道题的逐题精讲?

进入 GESPPASS 开始练习