<?php
$cash = 3300;
$summary = $cash;
100 => 23,
500 => 5,
1000 => 0,
5000 => 77
);
echo "<pre>";
echo "</pre>";
foreach ($bills as $key => $value){
$billSum[$key] = $key*$value;
}
echo "Доступно на данный момент: $amount <br>";
if ($cash > $amount) echo 'В банкомате недостаточно средств для выдачи денег';
else {
echo "Вам будет выдано: <br>";
foreach ($bills as $key => &$value)
{
if ($value != 0)
{
$arg = floor($cash / $key); if ($arg > $value){
$arg = $value;
}
$sum = $arg * $key;
$cash = $cash - $sum;
$value = $value - $arg;
if ($arg != 0) echo "$arg купюр номиналом $key на сумму $sum <br>";
}
}
echo "Общая сумма: $summary<br>";
}
echo "<pre>";
echo "</pre>";
?>
PD9waHAKJGNhc2ggPSAzMzAwOwokc3VtbWFyeSA9ICRjYXNoOwokYmlsbHMgPSBhcnJheSgKCQkxMDAgPT4gMjMsCgkJNTAwID0+IDUsCgkJMTAwMCA9PiAwLAoJCTUwMDAgPT4gNzcKCQkpOwoKa3Jzb3J0KCRiaWxscyk7CQplY2hvICI8cHJlPiI7CnByaW50X3IoJGJpbGxzKTsKZWNobyAiPC9wcmU+IjsKJGJpbGxTdW0gPSBhcnJheSgpOwoJZm9yZWFjaCAoJGJpbGxzIGFzICRrZXkgPT4gJHZhbHVlKXsKCQkkYmlsbFN1bVska2V5XSA9ICRrZXkqJHZhbHVlOwoJCX0KCQkkYW1vdW50ID0gYXJyYXlfc3VtKCRiaWxsU3VtKTsKCQllY2hvICLQlNC+0YHRgtGD0L/QvdC+INC90LAg0LTQsNC90L3Ri9C5INC80L7QvNC10L3RgjogJGFtb3VudCA8YnI+IjsKCSAgICBpZiAoJGNhc2ggPiAkYW1vdW50KSBlY2hvICfQkiDQsdCw0L3QutC+0LzQsNGC0LUg0L3QtdC00L7RgdGC0LDRgtC+0YfQvdC+INGB0YDQtdC00YHRgtCyINC00LvRjyDQstGL0LTQsNGH0Lgg0LTQtdC90LXQsyc7CQkKZWxzZSB7CgkKCmVjaG8gItCS0LDQvCDQ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