#include "stdio.h"
int f2(int a[],int n,int *x)
{ int i;
for (i=0;i<n;i++)
{if(*x==a[i])
return i; }
return -1;
}
main()
{ int a[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
int x,i;
printf("录入想要找的数:");
scanf("%d",&x);
i=f2(a,20,&x);
if(i==-1)
printf("对不起!没您有要找的数\n");
else
printf("元素下标为:%d\n",i);
}