fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int N,X,t=0;
  5. scanf("%d",&N);
  6. int A[N];
  7. for(int i=0;i<N;i++){
  8. scanf("%d",&A[i]);
  9. }
  10. scanf("%d",&X);
  11. for(int i=0;i<N;i++){
  12. if(A[i]==X){
  13. t=i;
  14. break;
  15. }
  16. }
  17. if(t==0){
  18. printf("-1");
  19. }else{
  20. printf("%d",t+1);
  21. }
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5320KB
stdin
4
10 20 30 40
5
stdout
-1