Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function task95(...$args) {
- if (!in_array(count($args), [1, 2]))
- throw new Exception('Incorrect parameters count');
- $radiusesProduct = count($args) === 1 ? pow($args[0], 2) / 16 : $args[0] * $args[1];
- return 2 * pi() * $radiusesProduct;
- }
- function test(...$args) {
- printf("%s => %s\n", implode(', ', $args), call_user_func_array('task95', $args));
- }
- foreach([[15, 20], [15, 15], [60]] as $data) test(...$data);
- /* результаты тестирования
- 15, 20 => 1884.9555921539
- 15, 15 => 1413.7166941154
- 60 => 1413.7166941154
- */
Add Comment
Please, Sign In to add comment