Var s,s1:string; a,b,code,i:integer; z:char; begin writeln('Введите выражение:'); readln(s); s1:=''; i:=1; while not (s[i] in ['+','-','*','/']) do begin s1:=s1+s[i]; i:=i+1; end; val(s1,a,code); z:=s[i]; s1:=''; i:=i+1; while s[i] <> '=' do begin s1:=s1+s[i]; i:=i+1; end; val(s1,b,code); case z of '+' : writeln(s,a+b); '-' : writeln(s,a-b); '*' : writeln(s,a*b); '/' : writeln(s,a/b); end; end.
Var x,y,v:real; b:string; begin writeln('Vvedite znak virajeniya (+, -, *, /)'); readln(b); writeln('Vvedite pervoe chislo'); readln(x); writeln('Vvedite vtoroe chislo'); readln(y); if b = '+' then v:=x+y; if b = '-' then v:=x-y; if b = '*' then v:=x*y; if b = '/' then v:=x/y; writeln(x, ' ', b, ' ', y, ' = ', v); end.
begin
writeln('Введите выражение:');
readln(s);
s1:=''; i:=1;
while not (s[i] in ['+','-','*','/']) do
begin
s1:=s1+s[i]; i:=i+1;
end;
val(s1,a,code);
z:=s[i];
s1:=''; i:=i+1;
while s[i] <> '=' do
begin
s1:=s1+s[i]; i:=i+1;
end;
val(s1,b,code);
case z of
'+' : writeln(s,a+b);
'-' : writeln(s,a-b);
'*' : writeln(s,a*b);
'/' : writeln(s,a/b);
end;
end.
Пример:
Введите выражение:
15-5=
15-5=10
x,y,v:real;
b:string;
begin
writeln('Vvedite znak virajeniya (+, -, *, /)');
readln(b);
writeln('Vvedite pervoe chislo');
readln(x);
writeln('Vvedite vtoroe chislo');
readln(y);
if b = '+' then v:=x+y;
if b = '-' then v:=x-y;
if b = '*' then v:=x*y;
if b = '/' then v:=x/y;
writeln(x, ' ', b, ' ', y, ' = ', v);
end.