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

查找数组中元素

时间:2022-10-09 19:57:38浏览次数:48  
标签:Set false 元素 item 查找 数组 position found

1.数组
7
10
32
24
15
44
要查找的数:26
2.伪代码
Set position to O
Set found to false
WHILE(position < 6AND found is false)
IF(numbers[position]equals searchitem)
Set found to true
Else
set position to position+1
IF(found is true)
Write "The item is found"
Else
Write "The item is not there"
3.测试
position:0
found:false
position:1
position:1
found:false
position:2
position:2
found:false
position:3
position:3
found:false
position:4
position:4
found:false
position:5
position:5
found:false
position:6
The item is not there

标签:Set,false,元素,item,查找,数组,position,found
From: https://www.cnblogs.com/7777xiaohu/p/16773435.html

相关文章

  • 查找数组中元素
    输入一个固定长度的数组,并输入一个要查找的数,给出能不能检索到的伪代码并测试代码:Setpositionto0SetfoundtofalseWHILE(position<6ANDfoundisfalse)I......
  • 查找数组中元素
    伪代码固定长度为6setpositionto0Write“entervalueforwhichtosearch”Readsearchitem=75Setfoundtotrueifsearchitemisthere......
  • 查找数组中的元素
    查找数组中的元素1.输入数组并输入六个元素,查找数组中的元素伪代码点击查看伪代码Integernumber[6]Setpositionto0SetfoundtoFALSEWHILE(position<6ANDf......
  • 【SpringBoot】解决redis 查找/删除缓存失败问题
     使用StringRedisTemplate.delete(key) 删除缓存数据失败,原因是序列化问题导致。 需要把key和hash都使用String的序列化方式 解决方法:创建一个新的配置类:@Con......
  • js中类数组对象转数组
    constobj={"0":"vv","1":12,"2":"male","3":123456,length:4}constarr=Array.from(obj);console.log(arr);//['vv',12,'male',123456]for(constitem......
  • linux 如何查找并结束僵尸进程
    当时用top命令查看时,发现zombie数字不是0,就说明有僵尸进程了。寻找僵尸进程ps-ef|grep杀掉该进程kill-9[pid]......
  • 表格与表单元素
    表格元素表格主要是用来展示数据的表格元素容器的标签table其他元素的标签thead:表头标签tbody:表体标签表格中的数据部分,如图中一行行的数据就是表体th:表格的一个......
  • 竞赛-6201. 找出前缀异或的原始数组
    参加竞赛的一道题中等难度给你一个长度为n的整数数组pref。找出并返回满足下述条件且长度为n的数组arr:pref[i]=arr[0]^arr[1]^...^arr[i].注意^表示......
  • js删除数组指定元素
    js删除数组指定元素constperson=[{id:0,name:'zhangsan'},{id:1,name:'wangwu'},{......
  • C++ 实现一个函数,函数完成如下功能: 1.函数的输入为一个数组,数组的成员个数不定(即:可能
    #include<iostream>#include<string>#include<windows.h>usingnamespacestd;boolfind_max_min(inta[],intlen,int*max,int*min){if(len<1)ret......