fork(3) download
  1. <?php
  2. $a = 0;
  3. $b = 0;
  4. $first = true;
  5. while (fscanf(STDIN, '%d%d', $a, $b)) {
  6. if ($first)
  7. {
  8. $min = $b;
  9. $max = $b;
  10. $total = $b;
  11. $count = 1;
  12. $first = false;
  13. }
  14. else
  15. {
  16. $total += $b;
  17. if ($b < $min) $min = $b;
  18. if ($b > $max) $max = $b;
  19. $count++;
  20. }
  21. }
  22. $avg = $total / $count;
  23. echo "Min: $min\n";
  24. echo "Max: $max\n";
  25. echo "Average: $avg\n";
  26. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
1    52
2    456
3    4516
5    4545
6     41
stdout
Min: 41
Max: 4545
Average: 1922