给定指定单链表和C++的searchValue函数,调用searchValue(head, 5)的返回值为多少?

tx504037 单选题 共 个子题

给定链表结构为:1 → 3 → 5 → 7 → nullptr searchValue函数实现如下:

int searchValue(ListNode* head, int target) {
    while (head != nullptr) {
        if (head->val == target) {
            return 1;
        }
        head = head->next;
    }
    return 0;
}
A

返回1

B

返回0

C

死循环,无法返回

D

返回-1

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧