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

查找数组中元素

时间:2022-10-09 19:34:37浏览次数:55  
标签:int 元素 75 查找 数组 found position searchitem

伪代码

固定长度为6

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

c语言代码

   include <stdio.h>
   int main(void)
   {
     int list[5] = {25,30,35,40,45};
     int i = 0,m;
     printf("Enter a number:");
     scanf("%d",&m);
     while (i<=5)
    {
     if (m != list[i])
     i++;
     else
     break;
    }
     if (i == 6) 
               printf("Can not found");
     else 
               printf("Number %d is found",m);
     return 0;
    }


标签:int,元素,75,查找,数组,found,position,searchitem
From: https://www.cnblogs.com/zhao-yuexi/p/16773365.html

相关文章