 program volchic_cel_chast (input,output);
 const n=25;
 var k,i,l,osn,chisl1,chisl2,res,d1,d2,fr:integer;
     s1,s2:array [1..1000] of char;
     resosn:string;
     t:boolean;
 begin
         writeln ('Введите основание системы счисления');
         writeln ('Это число может быть от 2 до 36');
         readln (osn);
         t:=true;
         writeln ('Ввод окончен');
         writeln ('Введите первое число');
         writeln ('По окончании ввода, введите !');
         d1:=1;
         repeat
                read (s1[d1]);
                if s1[d1]='!' then
                        begin
                        s1[d1]:='0';
                        T:=false
                        end
                else d1:=d1+1
         until not t;
         if d1<>1 then d1:=d1-1;
         t:=true;
         writeln ('Ввод окончен');
         writeln ('Введите второе число');
         writeln ('По окончании ввода, введите !');
         d2:=1;
         repeat
                read (s2[d2]);
                if s2[d2]='!' then
                        begin
                        s2[d2]:='0';
                        T:=false
                        end
                else d2:=d2+1
         until not t;
         t:=true;
         if d2<>1 then d2:=d2-1;
         for i:=1 to d2 do write(s2[i]);
         writeln ('Ввод окончен');
         writeln ('происходит решение задачи,пожалуйста подождите...');
         if d1<d2 then resosn:='0'
         else
                begin
                while t do
                        begin
                        for i:=1 to d2 do
                                begin
                                if s1[i]<s2[i] then
                                        begin
                                        fr:=64+osn+ord(s1[i])-ord(s2[i]);
                                        if (fr>57) and (fr<65) then s1[i]:=chr(fr-7) else s1[i]:=chr(fr);
                                        writeln (s1[i]);
                                        k:=i+1;
                                        while (s1[k]<'1') and (k<d1) do
                                                begin
                                                k:=k+1;
                                                if ord(s1[k])=65 then s1[k]:=CHR(64+osn)
                                                else s1[k]:=pred(s1[k]);
                                                writeln ('пожалуйста подождите еще...')
                                                end
                                        end
                               else if (ord(s1[i])>64) and (ord(s1[i])<58) and ((ord(s1[i])-(ord(s1[i])))<17)
                                     then s1[i]:=chr(ord(s1[i])-ord(s2[i])+41)
                                     else if (ord(s1[i])>64) and (ord(s1[i])>64) and ((ord(s1[i])-(ord(s1[i])))<10)
                                                then s1[i]:=chr(ord(s1[i])-ord(s2[i])+48)
                                                else s1[i]:=chr(ord(s1[i])-ord(s2[i])+64);
                                K:=1;
                                if succ(resosn[1])>chr(64+osn) then
                                while succ(resosn[k])<chr(64+osn) do
                                                if succ(resosn[k])<chr(64+osn) then resosn[k]:=succ(resosn[k])
                                                else k:=k+1;
                                for l:=d2 to d1 do if s1[i]<>'0' then t:=false;
                                if s1[d2]>s2[d2] then t:=true
                                end
                        end
                end;
  writeln ('целая часть от деления=',resosn);
  readln
  end.












