首页 > 其他分享 >查找数组中元素

查找数组中元素

时间:2022-10-09 19:46:32浏览次数:50  
标签:Set false 元素 查找 数组 position found searchitem

输入一个固定长度的数组,并输入一个要查找的数,给出能不能检索到的伪代码并测试

代码:
Set position to 0 Set found to false WHILE(position < 6 AND found is false) IF(numbers[position] equals searchitem) set found to true print numbers[position] ELSE Set position to position + 1

测试:
Set searchitem to 90
position = 0
found is false
position = 1
found is false
position = 2
found is false
position = 3
found is false
position = 4
found is false
position = 5
found is true
searchitem is 90

标签:Set,false,元素,查找,数组,position,found,searchitem
From: https://www.cnblogs.com/qingzao/p/16773388.html

相关文章