导航

查找数组中元素

Posted on 2022-10-09 17:38  20221301  阅读(15)  评论(1编辑  收藏  举报

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

  • Length=6 Read in array of values

            Set position to 0
    
            Weite “enter value for which to search”
    
            Read searchitem=75
    
            Set found to true if searchitem is there
    
            While (position <6)
    
            IF(found)
    
              Write “item is found”
    
              continue
    
                                                                   ELSE
    
                                                                 Write ”item is found”
    
    
    
                                                                 found Position 1-->75
    
                                                                 Continue can not found
    
                                                                   end