输入一个固定长度的数组,并输入一个要查找的数,给出能不能检索到的伪代码并测试
integer numbers[6] Write"Enter 6 integer numbers,one per line" Set index to 0 While(index<6) Read in numbers[index] Set index to index+1 Read in array of values Write “How many values?” Read lengthSet index to 0 WHILE (index < length) Read data[index] Set index to index + 1
我有如何查找的思路,但是自己写的代码一直显示出问题,我在网上找到了一个c语言代码,和我想的意思非常接近在C语言中,输入一个数,查找它在数组中的位置_百度知道 (baidu.com)
int main(void) { int aiNum[10] = {1,23,34,22,33,44,55,31,24,90}; int i; int number; printf("input NUMBER"); scanf("%d",&number); for(i=0;i<10;i++) { if(number == a[i]) break; } if(i>9) { printf("NOT FOUND NUMBER\n"); } else { printf("LOCATION:[%d]\n",i); } return(0); }
将其稍加改动即可得本题答案
标签:int,元素,number,查找,numbers,数组,printf From: https://www.cnblogs.com/liudi20221408/p/16774039.html