You will be given a count of wagons in a train n. On the next n lines you will receive how many people are going to get on that wagon. At the end print the whole train and after that the sum of the people in the train.
Examples:
My answer:
<?php $wagons = intval(readline()); $train = [];//empty array $sum = 0; for ($i = 0; $i < $wagons; $i++) { $current = intval(readline()); $train[$i] = $current; $sum += $current; } echo implode(' ', $train) . PHP_EOL; echo $sum;
622 questions
979 answers
129 comments
53 users