输入一个固定长度的数组,并输入一个要查找的数,给出能不能检索到的伪代码并测试
代码:
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