fork(3) download
  1. <?php
  2.  
  3.  
  4. $pupils = 30;
  5. $rhyme = 5;
  6. $presentPupils = range(1, $pupils);
  7.  
  8. for ($i = 1; count($presentPupils) >= $rhyme; ) {
  9. foreach ($presentPupils as $key => $value) {
  10. if ($i == $rhyme) {
  11. unset($presentPupils[$key]);
  12. $i = 1;
  13. continue;
  14. }
  15. $i++;
  16. }
  17. }
  18. $winners = implode(', ', $presentPupils);
  19. echo "Выигрышные места: $winners.";
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
Выигрышные места: 3, 4, 14, 27.