<?php
$input = '1+3*2/0.5=';
$number = 0;
$result = 0;
$count = 0;//считает количество цифр после точки
$op = '';
$decimalMark = '';
echo "Уберите лишний знак!\n";
}
for($i = 0; $i < $inputLength; $i++){
if($char == ','|| $char == '.'){
$decimalMark = $char;
}
if($char == '*' || $char =='+' || $char == '-' || $char == '=' || $char == '/'){
$count = 0;
$decimalMark = '';
if($op == '+'){
$result+= $number;
}elseif($op == '-'){
$result-= $number;
}elseif($op == '*'){
$result*= $number;
}elseif($op == '/'){
$result/= $number;
}else{
$result = $number;
}
$op = $char;
$number = 0;
if($decimalMark != ''){
$count++;
$number = $number + $char / pow(10, $count); }else{
$number = $number*10+$char;
}
}elseif($char == '.' || $char == ','){
}else{
echo "Неверный символ '$char'\n";
}
}
if($op == '='){
echo $result;
}
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAokaW5wdXQgPSAnMSszKjIvMC41PSc7CiRpbnB1dExlbmd0aCA9IG1iX3N0cmxlbigkaW5wdXQpOwokbnVtYmVyID0gMDsKJHJlc3VsdCA9IDA7CiRjb3VudCA9IDA7Ly/RgdGH0LjRgtCw0LXRgiDQutC+0LvQuNGH0LXRgdGC0LLQviDRhtC40YTRgCDQv9C+0YHQu9C1INGC0L7Rh9C60LgKJG9wID0gJyc7CiRkZWNpbWFsTWFyayA9ICcnOwppZihwcmVnX21hdGNoKCcvWy4sXXsyLH0vdScsICRpbnB1dCkpewoJZWNobyAi0KPQsdC10YDQuNGC0LUg0LvQuNGI0L3QuNC5INC30L3QsNC6IVxuIjsKCWV4aXQoKTsKfQpmb3IoJGkgPSAwOyAkaSA8ICRpbnB1dExlbmd0aDsgJGkrKyl7CgkkY2hhciA9IG1iX3N1YnN0cigkaW5wdXQsICRpLCAxKTsKCWlmKCRjaGFyID09ICcsJ3x8ICRjaGFyID09ICcuJyl7CgkJJGRlY2ltYWxNYXJrID0gJGNoYXI7Cgl9CglpZigk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