Вводится число 2
На экране число 2
Вводится знак +
На экране число 2
Вводится число 5
На экране число 5
Нажимается Enter
На экране число 7...
Вот так вот...
У кого-нибудь есть идеи???

readln(x1); { <--- читаем первое число }
readln(op); { <--- берем ЗНАК операции }
readln(x2); { <--- второе число }
case op of
'+': writeln(x1 + x2);
'-' : writeln(x1 - x2);
{ и так далее }
end;
uses crt;
var
first, second, ch: char;
begin
first := readkey; write(first);
ch := readkey; write(ch);
second := readkey; write(second);
readkey;
write('=');
case ch of
'+': writeln(ord(first) + ord(second) - 2 * ord('0'));
'-': writeln(ord(first) - ord(second));
'*': writeln((ord(first) - ord('0')) * (ord(second) - ord('0')));
'/': writeln((ord(first) - ord('0')) / (ord(second) - ord('0')));
end;
end.
работает только с однозначными числами, нужны двухзначные - возьми калькулятор за 20 рублей, и посчитай...
var k,i,j:integer;
z:char;
s:string;
begin
clrscr;
i:=0; j:=0;
readln(s);
k:=1; while ((pos(s[k],'+-/*')=0) and (k<length(s))) do inc (k);
val(copy(s,1,k-1),i,j);
z:=s[k];
val(copy(s,k+1,255),j,k);
case z of
'+': k:=i+j;
'-': k:=i-j;
'/': k:=i div j;
'*': k:=i*j;
end;
writeln;
writeln(i,' ',z,' ',j,'=',k);
end.
program Calc;
uses
CRT;
var
N1: extended;
N2: extended;
Op: char;
Key, ScanKey: char;
procedure GetKeys;
begin
Key := ReadKey;
if Key = #0 then
ScanKey := ReadKey
else
ScanKey := #0;
end;
procedure GetNumber(var N: extended);
var
WasPoint: boolean;
Order: integer;
DN: extended;
Minus: boolean;
begin
N := 0;
Order := 0;
DN := 1;
WasPoint := False;
if Key = '-' then begin
Write(Key);
GetKeys;
Minus := True;
end else
Minus := False;
repeat
if Key in ['0' .. '9'] then begin
Write(Key);
if WasPoint then begin
if (Order < 20) then begin
DN := DN / 10;
N := N + DN * (byte(Key) - 48);
Inc(Order);
end;
end else if (N < 1E+20) then
N := N * 10 + byte(Key) - 48
end;
if (Key in ['.', ',']) and not WasPoint then begin
Write(Key);
WasPoint := True;
end;
GetKeys;
until Key in ['+', '-', '*', '/', '^', 'v', 'l', '=', #13];
if Minus then
N := -N;
WriteLn;
end;
procedure GetOp;
begin
if Key in ['=', #13] then
repeat
GetKeys;
until Key in ['+', '-', '*', '/', '^', 'v', 'l'];
repeat
op := Key;
WriteLn(op);
GetKeys;
until Key in ['0' .. '9', '.', ',', '-'];
end;
begin
repeat
GetKeys;
GetNumber(N1);
GetOp;
GetNumber(N2);
case op of
'+': WriteLn(N1 + N2: 0: 30);
'-': WriteLn(N1 - N2: 0: 30);
'*': WriteLn(N1 * N2: 0: 30);
'/': if Abs(N2) > 1E-30 then
WriteLn(N1 / N2: 0: 30)
else
WriteLn('ERROR');
'^': if (N1 > 1E-30) and (N2 < 50) then
WriteLn(Exp(N2 * Ln(N1)): 0: 30)
else
WriteLn('ERROR');
'v': if (N1 > 1E-30) and (Abs(N2) > 0.02) then
WriteLn(Exp(Ln(N1) / N2): 0: 30)
else
WriteLn('ERROR');
'l': if (N1 > 1E-30) and (N2 > 1E-30) then
WriteLn(Ln(N1) / Ln(N2): 0: 30)
else
WriteLn('ERROR');
end;
until Abs(N2) < 1E-30;
end.