fork download
  1. #include <stdio.h>
  2. int no_search(int a[], int n, int x){
  3. return -1;
  4. }
  5.  
  6. int main(void) {
  7. int n,x,ans;
  8. int *a;
  9. scanf("%d,%d",&n,&x);
  10.  
  11. a = (int*)malloc(sizeof(int)*n);
  12. if(a==NULL){
  13. printf("ERROR\n");
  14. return 0;
  15. }
  16.  
  17. for(int i=0; i<n; i++){
  18. scanf("%d",&a[i]);
  19. }
  20.  
  21. ans = no_search(a,n,x);
  22. if(ans!=-1) printf("ans[%d]=%d\n",ans,a[ans]);
  23. else printf("not found\n");
  24.  
  25. free(a); //忘れずに!!
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5284KB
stdin
12 5
4 2 17 11 8 13 3 5 18 12 10 1
stdout
not found