Guest User

Untitled

a guest
May 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. function task95(...$args) {
  4. if (!in_array(count($args), [1, 2]))
  5. throw new Exception('Incorrect parameters count');
  6. $radiusesProduct = count($args) === 1 ? pow($args[0], 2) / 16 : $args[0] * $args[1];
  7. return 2 * pi() * $radiusesProduct;
  8. }
  9.  
  10. function test(...$args) {
  11. printf("%s => %s\n", implode(', ', $args), call_user_func_array('task95', $args));
  12. }
  13.  
  14. foreach([[15, 20], [15, 15], [60]] as $data) test(...$data);
  15.  
  16. /* результаты тестирования
  17. 15, 20 => 1884.9555921539
  18. 15, 15 => 1413.7166941154
  19. 60 => 1413.7166941154
  20. */
Add Comment
Please, Sign In to add comment