fork(1) download
  1. #include <stdio.h>
  2. int main() {
  3. int a[10]={2,5,3,8,9,6,10,7,4,12},i,x;
  4. printf("数组中的元素是:\n");
  5. for(i=0;i<10;i++) printf("%5d",a[i]);
  6. scanf("%d",&x);
  7. for (i=0;i<10;i++)
  8. if(a[i]==x) {printf("这个数在数组中第%d个数",i);break;}
  9. if(i==10) printf("数组中没有这个数字");
  10. return 0;
  11. }
Success #stdin #stdout 0s 5320KB
stdin
6
stdout
数组中的元素是:
    2    5    3    8    9    6   10    7    4   12这个数在数组中第5个数