#include <stdio.h>
#include <stdlib.h>
//線形探索
int linear_search(int a[],int n,int x){
//ここを書く
int i,ret=-1;
for(i=0; i<n; i++){
if(a[i]==x)
ret=i;
}
return ret;
}
int main(void) {
int n,x,i;
int *a;
int ans = -1;
a
= (int*)malloc(sizeof(int)*n
); if(a==NULL){
return -1;
}
for(i=0;i<n;i++){
}
ans = linear_search(a,n,x);
if(ans
!= -1) printf("a[%d] = %d\n",ans
,a
[ans
]); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCi8v57ea5b2i5o6i57SiCmludCBsaW5lYXJfc2VhcmNoKGludCBhW10saW50IG4saW50IHgpewoJLy/jgZPjgZPjgpLmm7jjgY8KCQoJaW50IGkscmV0PS0xOwoJZm9yKGk9MDsgaTxuOyBpKyspewoJCWlmKGFbaV09PXgpCgkJcmV0PWk7CgkJCgl9CgkKCXJldHVybiByZXQ7Cn0KCmludCBtYWluKHZvaWQpIHsKCWludCBuLHgsaTsKCWludCAqYTsKCWludCBhbnMgPSAtMTsKCXNjYW5mKCIlZCAlZCIsJm4sJngpOwoJYSA9IChpbnQqKW1hbGxvYyhzaXplb2YoaW50KSpuKTsKCWlmKGE9PU5VTEwpewoJCXByaW50ZigiRVJST1JcbiIpOwoJCXJldHVybiAtMTsKCX0KCWZvcihpPTA7aTxuO2krKyl7CgkJc2NhbmYoIiVkIiwmYVtpXSk7Cgl9CglhbnMgPSBsaW5lYXJfc2VhcmNoKGEsbix4KTsKCWlmKGFucyAhPSAtMSkgcHJpbnRmKCJhWyVkXSA9ICVkXG4iLGFucyxhW2Fuc10pOwoJZWxzZSBwcmludGYoIm5vdCBmb3VuZFxuIik7CglmcmVlKGEpOwoJcmV0dXJuIDA7Cn0K