<?php
$input = "243+6743-78*2=";
$number = 0;
$result = 0;
$op = "";
for ($i = 0; $i < $inputLength; $i++) {
if ($char == "*" || $char == "+" || $char == "-" || $char == "/") {
if ($op == "") {
$result = $number;
} elseif ($op == "*") {
$result = $result * $number;
} elseif ($op == "+") {
$result = $result + $number;
} elseif ($op == "-") {
$result = $result - $number;
} elseif ($op == "/") {
$result = $result / $number;
}
$number = 0;
$op = $char;
$number = $number * 10 + intval($char); } elseif ($char == "=") {
if ($op == "+") {
$result = $result + $number;
} elseif ($op == "*") {
$result = $result * $number;
} elseif ($op == "-") {
$result = $result - $number;
} elseif ($op == "/") {
$result = $result / $number;
}
} else {
echo "Неверный символ: \"$char\". Калькулятор не может обрабатывать подобные символы!\n";
}
}
echo "{$input}{$result}\n";
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCdVVEYtOCcpOwoKJGlucHV0ID0gIjI0Mys2NzQzLTc4KjI9IjsKJGlucHV0TGVuZ3RoID0gbWJfc3RybGVuKCRpbnB1dCk7CiRudW1iZXIgPSAwOwokcmVzdWx0ID0gMDsKJG9wID0gIiI7Cgpmb3IgKCRpID0gMDsgJGkgPCAkaW5wdXRMZW5ndGg7ICRpKyspIHsKCSRjaGFyID0gbWJfc3Vic3RyKCRpbnB1dCwgJGksIDEpOwoJaWYgKCRjaGFyID09ICIqIiB8fCAkY2hhciA9PSAiKyIgfHwgJGNoYXIgPT0gIi0iIHx8ICRjaGFyID09ICIvIikgewoJCWlmICgkb3AgPT0gIiIpIHsKCQkgICAgJHJlc3VsdCA9ICRudW1iZXI7CgkJfSBlbHNlaWYgKCRvcCA9PSAiKiIpIHsKCQkJJHJlc3VsdCA9ICRyZXN1bHQgKiAkbnVtYmVyOwoJCX0gZWxzZWlmICgkb3AgPT0gIisiKSB7CgkJCSRyZXN1bHQgPSAkcmVzdWx0ICsgJG51bWJlcjsKCQl9IGVsc2VpZiAoJG9wID09ICItIikgewoJCQk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