fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int T[11]={3,8,2,4,7,6,5,9,0,1};
  5. int n=10;
  6. int x;
  7. scanf("%d",&x);
  8. int i;
  9. int last = T[n - 1];
  10. T[n - 1] = x;
  11.  
  12. i = 0;
  13. while (T[i] != x) {
  14. i++;
  15. }
  16.  
  17. // 元の値を戻す
  18. T[n - 1] = last;
  19.  
  20. if (i < n - 1 || T[n - 1] == x) {
  21. printf("Found at %d\n", i + 1);
  22. } else {
  23. printf("Not found\n");
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 5308KB
stdin
5
stdout
Found at 7