- paste
1
- 2022-11-28 19:45:48 @
#include<stdio.h>
#define N =10
int search(int *list, int n,int x);
int main()
{
int repeat;
int n,x;
int a[N];
scanf("%d",&repeat);
while(repeat>0)
{
scanf("%d",&n);
for(int i=0;i<n;i ++)
scanf("%d",&a[i]);
scanf("%d",&x);
int m =search(a, n, x);
if(m==-1)
printf("Not found");
else
printf("index = %d\n", m);
repeat--;
}
return 0;
}
int search(int *list, int n,int x);
{
int i;
for(i=0;i<n;i ++)
{
if(list[i] == x)
{
return i;
break;
}
}
return -1;
}
0 comments
No comments so far...