fork download
  1. #include <stdio.h>
  2. #include <float.h>
  3.  
  4. int main(void)
  5. {
  6. int x, i;
  7. double n, a = -DBL_MAX, b = -DBL_MAX;
  8.  
  9. printf("Input <X> : ");
  10. scanf("%d", &x);
  11.  
  12. for (i = 1 ; i <= x ; i++) {
  13. printf("Input <n%d> : ", i);
  14. scanf("%lf", &n);
  15.  
  16. if (n > a) {
  17. a = n;
  18. } else if (n > b) {
  19. b = n;
  20. }
  21. }
  22.  
  23. printf(" 1 = %.3f\n 2 = %.3f\n", a, b);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 1836KB
stdin
3
1.2
-3.4
1.2
stdout
Input <X> : Input <n1> : Input <n2> : Input <n3> :  1 = 1.200
 2 = 1.200