fork(1) download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a[10],i,max,min,p_max=0,p_min=0;
  5. for(i=0;i<10;i++)
  6. scanf("%d",&a[i]);
  7. max=a[0];
  8. min=a[0];
  9. for(i=1;i<10;i++)
  10. {
  11. if(a[i]>max)
  12. {
  13. max=a[i];
  14. p_max=i+1;
  15. }
  16. if(a[i]<min)
  17. {
  18. min=a[i];
  19. p_min=i+1;
  20. }
  21. }printf("No.%d is the max number %d\n",p_max,max);
  22. printf("No.%d is the min number %d\n",p_min,min);
  23. }
Success #stdin #stdout 0s 15240KB
stdin
2
3
7
1
9
5
8
8
4
2
stdout
No.5 is the max number 9
No.4 is the min number 1