Предмет:
Тип роботи:
Курсова робота
К-сть сторінок:
69
Мова:
Українська
style="text-align: justify;">if (a[n]<>'0') then
begin
zn1:=strtozr(a[i]);
zn2:=strtozr(a[n]);
zn2:=divzr(zn1,zn2);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end else begin rezul:='Делениенанульнельзя'; exit; end;
end;
'm': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[i]);
zn2:=strtozr(a[n]);
if (a[n]<>'0') then
begin
zn1:=divzr(zn1,zn2);
zn:=ZRToLongInt(zn1,-1);
zn:=multzr(zn,zn2);
zn1:=strtozr(a[i]);
zn2:=subzr(zn1,zn);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end
else begin rezul:='Делитьнанульнельзя'; exit; end;
end;
'a': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zt2:='';
zt:='';
zt1:='';
zn1:=strtozr(a[i]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt:=zrtostr(zn2)+zt;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
zn1:=strtozr(a[n]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt1:=zrtostr(zn2)+zt1;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
obrazec1:=length(zt);
obrazec2:=length(zt1);
if (obrazec1>obrazec2) then
begin
obrazec1:=obrazec1-obrazec2;
for r:=1 to trunc(obrazec1) do
zt1:='0'+zt1;
end
else
begin
obrazec1:=obrazec2-obrazec1;
for r:=1 to trunc(obrazec1) do
zt:='0'+zt;
end;
obrazec1:=length(zt);
for r:=trunc(obrazec1) downto 1 do
zt2:= inttostr( strtoint( zt[r]) and strtoint (zt1[r]))+zt2;
p:=1;j:=0;
zn2:=inttozr(0);
zn1:=inttozr(1);
for r:=length(zt2) downto 1 do
begin
zn2:=sumzr(zn2,MultZR(zn1,strtozr(zt2[r])));
zn1:=multzr(zn1,inttozr(2));
end;
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
'l': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[n]);
zn1:=ZRToLongInt(zn1,-1);
zn2:=strtozr(a[i]);
zn2:=ZRToLongInt(zn2,-1);
zn:=inttozr(0);
while (ComparisonZR(zn,zn1)=(-1)){ or (ComparisonZR(zn,zn1)=0))} do
begin
zn:=sumzr(zn,inttozr(1));
zn2:=multzr(zn2,inttozr(2));
end;
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
'h': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[n]);
zn1:=ZRToLongInt(zn1,-1);
zn2:=strtozr(a[i]);
zn2:=ZRToLongInt(zn2,-1);
zn:=inttozr(0);
while (ComparisonZR(zn,zn1)=(-1)){ or (ComparisonZR(zn,zn1)=0))} do
begin
zn:=sumzr(zn,inttozr(1));
zn2:=divzr(zn2,inttozr(2));
end
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
end;
end;
for i:=1 to q do
if (a[i]<>'|') then
begin
case b[i] of
'+': begin n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[i]);
zn2:=strtozr(a[n]);
zn2:=sumzr(zn1,zn2);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
'-': begin n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[i]);
zn2:=strtozr(a[n]);
zn2:=subzr(zn1,zn2);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
'x': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zt2:='';
zt:='';
zt1:='';
zn1:=strtozr(a[i]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt:=zrtostr(zn2)+zt;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
zn1:=strtozr(a[n]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt1:=zrtostr(zn2)+zt1;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
obrazec1:=length(zt);
obrazec2:=length(zt1);
if (obrazec1>obrazec2) then
begin
obrazec1:=obrazec1-obrazec2;
for r:=1 to trunc(obrazec1) do
zt1:='0'+zt1;
end
else
begin
obrazec1:=obrazec2-obrazec1;
for r:=1 to trunc(obrazec1) do
zt:='0'+zt;
end;
obrazec1:=length(zt);
for r:=trunc(obrazec1) downto 1 do
zt2:= inttostr( strtoint( zt[r]) xor strtoint (zt1[r]))+zt2;
p:=1;j:=0;
zn2:=inttozr(0);
zn1:=inttozr(1);
for r:=length(zt2) downto 1 do
begin
zn2:=sumzr(zn2,MultZR(zn1,strtozr(zt2[r])));
zn1:=multzr(zn1,inttozr(2));
end;
a[n]:=zr_e(zrtostr(zn2)); //a[n]:=Floattostr(Zrtoreal(zn2));
a[i]:='|';
end;
'o': begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zt2:='';
zt:='';
zt1:='';
zn1:=strtozr(a[i]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt:=zrtostr(zn2)+zt;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
zn1:=strtozr(a[n]);
zn1:=ZRToLongInt(zn1,-1);
while (ComparisonZR(zn1,inttozr(0))<>0) do
begin
zn2:=divzr(zn1,inttozr(2));
zn2:=ZRToLongInt(zn2,-1) ;
zn2:=multzr(zn2,inttozr(2));
zn2:= SubZR(zn1,zn2);
zt1:=zrtostr(zn2)+zt1;
zn1:=divzr(zn1,inttozr(2));
zn1:=ZRToLongInt(zn1,-1);
end;
obrazec1:=length(zt);
obrazec2:=length(zt1);
if (obrazec1>obrazec2) then
begin
obrazec1:=obrazec1-obrazec2;
for r:=1 to trunc(obrazec1) do
zt1:='0'+zt1;
end
else
begin
obrazec1:=obrazec2-obrazec1;
for r:=1 to trunc(obrazec1) do
zt:='0'+zt;
end;
obrazec1:=length(zt);
for r:=trunc(obrazec1) downto 1 do
zt2:= inttostr( strtoint( zt[r]) or strtoint (zt1[r]))+zt2;
p:=1;j:=0;
zn2:=inttozr(0);
zn1:=inttozr(1);
for r:=length(zt2) downto 1 do
begin
zn2:=sumzr(zn2,MultZR(zn1,strtozr(zt2[r])));
zn1:=multzr(zn1,inttozr(2));
end;
a[n]:=zr_e(zrtostr(zn2)); //a[n]:=Floattostr(Zrtoreal(zn2);
a[i]:='|';
end;
end;
end;
rezul:=a[t];
end;
function DestoDr(x2: string;y:integer): string;
var
str:string;
x,x1:extended;
m:int64;