Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $shop = [];
- while (($arrgs = readline()) !== "buy") {
- $arr = explode(" ", $arrgs);
- $articul = $arr[0];
- $price = $arr[1];
- $size = $arr[2];
- if (!key_exists($articul, $shop)) {
- $shop[$articul][] = $price;
- $shop[$articul][] = $size;
- } else {
- if ($shop[$articul][0] >= $price) {
- $shop[$articul][0] = $price;
- $shop[$articul][1] += $size;
- }
- }
- }
- foreach ($shop as $key => $value) {
- $prices = $value[1] * $value[0];
- printf("$key -> %.2f" . PHP_EOL, $prices);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement