1143:0 start algorithm 50--Array lookup number time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:1910 accepted:777
[Submit] [Status] [Web Board] Description
Finds a number in the given array
Input
Multiple sets of tests, enter 1 integers n (n<20) and then n integers in the first row of each group
Enter 1 integer m in the second line
Output
Finds the first occurrence of the number M's subscript position in the first row of n integers and outputs the output if no is found
Sample Input
3 4 5 654 2 2 2 22
Sample Output
10
Source
0 Starting point Learning algorithm
1#include <stdio.h>2 intMain () {3 intn,a[ -];4 while(SCANF ("%d", &n)! =EOF) {5 for(intI=0; i<n;i++){6scanf"%d",&a[i]);7 }8 intm,t,flag=1;9scanf"%d",&m);Ten for(intI=0; i<n;i++){ One if(m==A[i]) { At=i; -flag=0; - Break; the } - } - if(flag) -printf"no\n"); + Else -printf"%d\n", T); + } A return 0; at}
1143:0 start-up algorithm 50--the number of lookups in an array