program arith; type tdata=record t:array[1..1100] of char; n:word; end; var ta,tta:longint; t:array[1..600] of tdata; a,b:tdata; na,nb:integer; c,muv:char; i,j,k:integer; lines:integer; procedure addtoline(var a:tdata;c:char); { var i:integer;} begin { i:=1; while (a[i]<>#0) do inc(i);a[i]:=c;} inc(a.n);a.t[a.n]:=c; end; function linelength(a:tdata):integer; { var i:integer;} begin { i:=1; while (a[i]<>#0) do inc(i);}linelength:=a.n; end; procedure kiirlines; var i,j,k:integer; begin j:=0; for i:=1 to lines do if (linelength(t[i])>j) then j:=linelength(t[i]); for i:=1 to lines do for k:=linelength(t[i]) to j-1 do addtoline(t[i],' '); for i:=1 to lines do begin for k:=j downto 1 do write(t[i].t[k]); writeln; end; writeln; end; procedure osszead(jelk:integer); var i,j,k:integer; aa,bb,cc:array[1..600] of integer; begin { fillchar(k,sizeof(k),0);} fillchar(aa,sizeof(aa),0);fillchar(bb,sizeof(bb),0);fillchar(cc,sizeof(cc),0); for i:=na downto 1 do aa[i]:=ord(a.t[na-i+1])-ord('0'); for i:=nb downto 1 do bb[i]:=ord(b.t[nb-i+1])-ord('0'); j:=na;if j9) do begin dec(cc[i],10);inc(cc[i+1]);end; end; k:=0; for i:=j+2 downto 1 do if (cc[i]<>0)and(k9) do begin dec(dd[j],10);inc(dd[j+1]);end; end; for j:=1 to na+2 do z[i,j]:=dd[j]; end; for i:=1 to nb do begin inc(lines); fillchar(dd,sizeof(dd),0); for j:=1 to na+2 do dd[j]:=z[bb[i],j]; for j:=1 to na+3 do begin inc(cc[j+i-1],dd[j]);end; for j:=1 to i-1 do addtoline(t[lines],' '); k:=0; for j:=na+2 downto 1 do if (dd[j]<>0)and(k1) then begin inc(lines); for i:=1 to k do addtoline(t[lines],'-'); end; for j:=1 to na+nb+1 do begin while (cc[j]<0) do begin inc(cc[j],10);dec(cc[j+1]);end; while (cc[j]>9) do begin dec(cc[j],10);inc(cc[j+1]);end; end; inc(lines); k:=0; for i:=na+nb+3 downto 1 do if (cc[i]<>0)and(k='0') then addtoline(a,c); until (c='*')or(c='+')or(c='-'); muv:=c; repeat read(c); if (c<='9')and(c>='0') then addtoline(b,c); until eoln; for i:=linelength(a) downto 1 do addtoline(t[1],a.t[i]); for i:=linelength(b) downto 1 do addtoline(t[2],b.t[i]); addtoline(t[2],muv); j:=linelength(t[1])-linelength(t[2]); if (j<0) then begin for i:=1 to -j do addtoline(t[1],' '); end else begin for i:=1 to j do addtoline(t[2],' '); end; for i:=linelength(t[1]) downto 1 do addtoline(t[3],'-'); lines:=3; na:=linelength(a); nb:=linelength(b); if (muv='+') then osszead(1); if (muv='-') then osszead(-1); if (muv='*') then szor; kiirlines; end; end.