Предмет:
Тип роботи:
Курсова робота
К-сть сторінок:
69
Мова:
Українська
justify;">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;
end;
end;
end;
for i:=d+1 to z-1 do
begin
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[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;
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[i]:='|';
end;
end;
end;
end;
end;
until d=0 ;
rezul2:=a[t];
a[t]:='|';
end;
function Rezul (q:integer) : string;
var z,d,n,r,p:integer;
begin
repeat
d:=0;
z:=0;
for i:=1 to q do
if b[i]='(' then d:=i;
for i:=d to q do
if b[i]=')' then
begin
z:=i;
break;
end;
b[d]:='0';
b[z]:='0';
if ((z<>0) and (d<>0)) then begin
for i:=d+1 to z-1 do
begin
if ((a[i]<>'|') and (b[i]='^')) then
begin
n:=i+1;
while (a[n]='|') do
begin
n:=n+1;
end;
zn1:=strtozr(a[i]);
zn2:=strtozr(a[n]);
zn2:=powerzr(zn1,zn2);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end;
end;
for i:=d+1 to z-1 do
begin
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:=multzr(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]);
if (a[n]<>'0') then
begin
zn2:=divzr(zn1,zn2);
a[n]:=zr_e(zrtostr(zn2));
a[i]:='|';
end
else begin rezul:='Делитьнанульнельзя'; exit; end;
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;