fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //線形探索
  5. int linear_search(int a[],int n,int x){
  6. //ここを書く
  7. }
  8.  
  9. int main(void) {
  10. int n,x,i;
  11. int *a;
  12. int ans = -1;
  13. scanf("%d %d",&n,&x);
  14. a = (int*)malloc(sizeof(int)*n);
  15. if(a==NULL){
  16. printf("ERROR\n");
  17. return -1;
  18. }
  19. for(i=0;i<n;i++){
  20. scanf("%d",&a[i]);
  21. }
  22. ans = linear_search(a,n,x);
  23. if(ans != 0) printf("Found_%d_%ds\n",ans,x);
  24. else printf("not found\n");
  25. free(a);
  26. return 0;
  27. }
Success #stdin #stdout 0s 5280KB
stdin
50 5
12	3	4	12	11	5	7	15	18	0	0	5	10	6	15	6	4	10	8	16	12	9	10	11	12	9	5	7	10	14	3	17	11	10	7	15	5	2	6	3	19	7	8	16	13	3	18	10	19	5
stdout
not found