Program Matcv; var sous:byte; a,b,vysl: array [1..2000] of byte; ad,bd,i,j,pom1,pom2,a1,b1:integer; z:char; konec:boolean; Function preved(znak:char):byte; Begin case znak of '0': preved:=0; '1'..'9': preved:=ord(znak)-ord('1')+1; 'A'..'Z': preved:=ord(znak)-ord('A')+10; end; end; Function zpet(cislo:byte):char; begin case cislo of 0: zpet:='0'; 1..9: zpet:= chr(ord('1')+cislo-1); 10..35:zpet:= chr (ord('A')+cislo -10); end; end; function max(u1,u2:integer):byte; begin if u1 0 do Begin i:=0; repeat read(z); i:=i+1; a[i]:=preved(z); until (z=' '); ad:=i-1; i:=0; repeat read(z); i:=i+1; b[i]:=preved(z); until eoln; bd:=i; j:=0; pom2:=0; if sous = 1 then begin for i:=1 to ad do write(zpet(a[i])); write(' + '); for i:=1 to bd do write(zpet(b[i])); write(' = '); if a[1]=0 then ad:=0; if b[1]=0 then bd:=0; if ad+bd=0 then write(0); for i:=1 to ad+bd do write(1); writeln; end else begin for i:= 0 to max(ad,bd) do begin if ad-i>0 then a1:=a[ad-i] else a1:=0; if bd-i>0 then b1:=b[bd-i] else b1:=0; pom1:=a1+b1+ pom2; pom2:=0; while pom1 >= sous do begin pom2:=pom2+1; pom1:=pom1-sous; end; j:=j+1; vysl[j]:=pom1; end; for i:=1 to ad do write(zpet(a[i])); write(' + '); for i:=1 to bd do write(zpet(b[i])); write(' = '); if vysl[j]<>0 then write(zpet(vysl[j])); for i:=j-1 downto 1 do write(zpet(vysl[i])); writeln; end; Readln(sous); end; end.