<?php
$operator = array ( '+' , '-' , '*' , '=' , '/' ) ;
$input = '-2.43+3.62/2.1*9.02=' ;
$numberText = '' ;
$result = 0 ;
$op = '' ;
for ( $i = 0 ; $i < $inputLength ; $i ++ ) {
if ( $char == '=' ) {
switch ( $op ) {
case '+' :
break ;
case '-' :
break ;
case '*' :
break ;
case '/' :
break ;
}
} else {
switch ( $op ) {
case '' :
break ;
case '+' :
break ;
case '-' :
break ;
case '*' :
break ;
case '/' :
break ;
}
}
echo "op = [$op ], number = [$numberText ], result = [$result ], char = [$char ]\n " ;
$numberText = '' ;
$op = $char ;
$numberText .= $char ;
} else {
echo "Непонятный символ. Работа программы прекращена\n " ;
}
}
echo "{$input} {$result} " ;
PD9waHAKICAgIG1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwogICAgCiAgICAkb3BlcmF0b3IgPSBhcnJheSgnKycsICctJywgJyonLCAnPScsICcvJyk7CiAgICAKICAgICRpbnB1dCA9ICctMi40MyszLjYyLzIuMSo5LjAyPSc7CiAgICAkaW5wdXRMZW5ndGggPSBtYl9zdHJsZW4oJGlucHV0KTsKICAgIAogICAgJG51bWJlclRleHQgPSAnJzsKICAgICRyZXN1bHQgPSAwOwogICAgJG9wID0gJyc7CiAgICAKICAgIGZvciAoJGkgPSAwOyAkaSA8ICRpbnB1dExlbmd0aDsgJGkrKykgewogICAgICAgICRjaGFyID0gbWJfc3Vic3RyKCRpbnB1dCwgJGksIDEpOwogICAgICAgIAogICAgICAgIGlmIChpbl9hcnJheSgkY2hhciwgJG9wZXJhdG9yKSkgewogICAgICAgICAgICBpZiAoJGNoYXIgPT0gJz0nKSB7CiAgICAgICAgICAgICAgICBzd2l0Y2ggKCRvcCkgewogICAgICAgICAgICAgICAgICAgIGNhc2UgJysnOiAKICAgICAgICAgICAgICAgICAgICAgICAgJHJlc3VsdCArPSBmbG9hdHZhbCgkbnVtYmVyVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIGNhc2UgJy0nOgogICAgICAgICAgICAgICAgICAgICAgICAkcmVzdWx0IC09IGZsb2F0dmFsKCRudW1iZXJUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgY2FzZSAnKic6CiAgICAgICAgICAgICAgICAgICAgICAgICRyZXN1bHQgKj0gZmxvYXR2YWwoJG51bWJlclRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICBjYXNlICcvJzoKICAgICAgICAgICAgICAgICAgICAgICAgJHJlc3VsdCAvPSBmbG9hdHZhbCgkbnVtYmVyVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3dpdGNoICgkb3ApIHsKICAgICAgICAgICAgICAgICAgICBjYXNlICcnOgogICAgICAgICAgICAgICAgICAgICAgICAkcmVzdWx0ID0gZmxvYXR2YWwoJG51bWJlclRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICBjYXNlICcrJzoKICAgICAgICAgICAgICAgICAgICAgICAgJHJlc3VsdCArPSBmbG9hdHZhbCgkbnVtYmVyVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIGNhc2UgJy0nOgogICAgICAgICAgICAgICAgICAgICAgICAkcmVzdWx0IC09IGZsb2F0dmFsKCRudW1iZXJUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgY2FzZSAnKic6CiAgICAgICAgICAgICAgICAgICAgICAgICRyZXN1bHQgKj0gZmxvYXR2YWwoJG51bWJlclRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICBjYXNlICcvJzoKICAgICAgICAgICAgICAgICAgICAgICAgJHJlc3VsdCAvPSBmbG9hdHZhbCgkbnVtYmVyVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVjaG8gIm9wID0gWyRvcF0sIG51bWJlciA9IFskbnVtYmVyVGV4dF0sIHJlc3VsdCA9IFskcmVzdWx0XSwgY2hhciA9IFskY2hhcl1cbiI7CiAgICAgICAgICAgICRudW1iZXJUZXh0ID0gJyc7CiAgICAgICAgICAgICRvcCA9ICRjaGFyOwogICAgICAgIH0gZWxzZWlmIChpc19udW1lcmljKCRjaGFyKSB8fCAkY2hhciA9PSAnLicpIHsKICAgICAgICAgICAgJG51bWJlclRleHQgLj0gJGNoYXI7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZWNobyAi0J3QtdC/0L7QvdGP0YLQvdGL0Lkg0YHQuNC80LLQvtC7LiDQoNCw0LHQvtGC0LAg0L/RgNC+0LPRgNCw0LzQvNGLINC/0YDQtdC60YDQsNGJ0LXQvdCwXG4iOwogICAgICAgICAgICBleGl0KCk7CiAgICAgICAgfQogICAgfQogICAgCiAgICBlY2hvICJ7JGlucHV0fXskcmVzdWx0fSI7
stdout
op = [], number = [], result = [0], char = [-]
op = [-], number = [2.43], result = [-2.43], char = [+]
op = [+], number = [3.62], result = [1.19], char = [/]
op = [/], number = [2.1], result = [0.56666666666667], char = [*]
op = [*], number = [9.02], result = [5.1113333333333], char = [=]
-2.43+3.62/2.1*9.02=5.1113333333333