fork(1) download
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. int a[10], n, max, min, maxPos, minPos;
  5. for (n=0; n<10; n++)
  6. {
  7. scanf("%d", &a[n]);
  8. }
  9. max = min = a[0];
  10. maxPos = minPos =0;
  11. for (n=0; n<10; n++)
  12. {
  13. if (a[n]>=max)
  14. {
  15. max = a[n];
  16. maxPos = n;
  17. }
  18. else if (a[n]<=min)
  19. {
  20. min = a[n];
  21. minPos =n ;
  22. }
  23. }
  24. printf("max=%d, pos=%d\n", max, maxPos);
  25. printf("min=%d, pos=%d\n", min, minPos);
  26. return 0;
  27. }
Success #stdin #stdout 0s 544KB
stdin
1 2 3 4 5 6 7 8 9 0
stdout
max=9, pos=8
min=0, pos=9