fork download
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int no_search(int a[],int n,int x){//no_search関数の挿入
  5. int ret=-1;//常に-1を返す
  6. return ret;//
  7. }
  8.  
  9. int main(void) {
  10. // your code goes here
  11. int n,x,i;
  12. int *a;
  13. int ans=-1;
  14. scanf("%d%d",&n,&x);//n,xに入力させる
  15.  
  16. a=(int*)malloc(sizeof(int)*n);//aの動的確保をする
  17. if(a==NULL){//エラー処理
  18. printf("ERROR");
  19. return -1;//エラーだとしても-1を返す
  20. }
  21. for(i=0;a[i]<=n;i++){
  22. scanf("%d",&a[i]);//動的確保したaの配列に入力させる
  23. }
  24. ans=no_search(a[i],n,x);
  25. if(ans!=-1){
  26. printf("a[%d]%d\n",ans,a[ans]);
  27. }else{
  28. printf("not found\n");
  29. }
  30. free(a);
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5304KB
stdin
12 5
4 2 17 11 8 13 3 5 18 12 10 1
stdout
not found