<?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 'В банкомате недостаточно средств для выдачи денег<br>';
}
else {
echo "Вам будет выдано: <br>";
foreach ($bills as $nominal => &$count)
{
if ($value != 0)
{
$arg = floor($cash / $nominal); if ($arg > $count){
$arg = $count;
}
$sum = $arg * $nominal;
$cash -= $sum;
$count -= $arg;
if ($arg != 0)
{
echo "$arg купюр номиналом $nominal на сумму $sum <br>";
}
}
}
echo "Общая сумма: $summary<br>";
}
echo "<pre>";
echo "</pre>";
PD9waHAKJGNhc2ggPSAzMzAwOwokc3VtbWFyeSA9ICRjYXNoOwokYmlsbHMgPSBhcnJheSgKCQkxMDAgPT4gMjMsCgkJNTAwID0+IDUsCgkJMTAwMCA9PiAwLAoJCTUwMDAgPT4gNzcKCQkpOwogCmtyc29ydCgkYmlsbHMpOwkKZWNobyAiPHByZT4iOwpwcmludF9yKCRiaWxscyk7CmVjaG8gIjwvcHJlPiI7CiRiaWxsU3VtID0gYXJyYXkoKTsKCWZvcmVhY2ggKCRiaWxscyBhcyAka2V5ID0+ICR2YWx1ZSl7CgkJJGJpbGxTdW1bJGtleV0gPSAka2V5KiR2YWx1ZTsKCQl9CgkJJGFtb3VudCA9IGFycmF5X3N1bSgkYmlsbFN1bSk7CgkJZWNobyAi0JTQvtGB0YLRg9C/0L3QviDQvdCwINC00LDQvdC90YvQuSDQvNC+0LzQtdC90YI6ICRhbW91bnQgPGJyPiI7CgkgICAgaWYgKCRjYXNoID4gJGFtb3VudCkgCgkgICAgewoJICAgICAgIGVjaG8gJ9CSINCx0LDQvdC60L7QvNCw0YLQtSDQvdC10LTQvtGB0YLQsNGC0L7Rh9C90L4g0YHRgNC10LTRgdGC0LIg0LTQu9GPINCy0YvQtNCw0YfQuCDQtNC10L3QtdCzPGJy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