Guest User

Untitled

a guest
Jul 11th, 2019
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $shop = [];
  4. while (($arrgs = readline()) !== "buy") {
  5. $arr = explode(" ", $arrgs);
  6. $articul = $arr[0];
  7. $price = $arr[1];
  8. $size = $arr[2];
  9. if (!key_exists($articul, $shop)) {
  10. $shop[$articul][] = $price;
  11. $shop[$articul][] = $size;
  12. } else {
  13. if ($shop[$articul][0] >= $price) {
  14. $shop[$articul][0] = $price;
  15. $shop[$articul][1] += $size;
  16. }
  17. }
  18. }
  19. foreach ($shop as $key => $value) {
  20. $prices = $value[1] * $value[0];
  21. printf("$key -> %.2f" . PHP_EOL, $prices);
  22. }
RAW Paste Data