#include<stdio.h>
#include<stdlib.h>
int main(){
int n = 0;
while(scanf("%d",&n)!=EOF){
int* A=(int*)malloc(sizeof(int )*n);
for(int i = 0 ; i < n ;i++){
scanf("%d",&A[i]);
}
int t;
scanf("%d",&t);
int i = 0 ;
for( ; i < n ;i++){
if(A[i]==t){
t=i;
break;
}
}
if(i==n){
printf("-1\n");
}else{
printf("%d\n",t);
}
free(A);
}
return 0;
}
结果如下:
标签:KY158,int,xC,scanf,++,printf From: https://www.cnblogs.com/llllmz/p/17962371