The task itself A given non-negative integer s in the m-year number system. What will this number look like in a k-year system? Write the procedure perevod (m, k, s), which displays the translated number. If the number starts with a letter, then it should not be zero. It is known that the condition is fulfilled: 2 ≤ m, k ≤ 36 To represent the numbers 10 ... 35, use capital Latin letters A ... Z, respectively. The number of digits of the number for translation is not more than 1000.
I seem to have done everything but it does not work!
Var m, k: integer; s: string; procedure perevod(m, k: integer; s: string); var z,i:longint; str:String; const digit:string[16]='0123456789ABCDEF'; begin if (m<=2) and (m>=36) then writeln('Введите число в соответствии с CC:'); if (k<=2) and (k>=36) then writeln('Введите число в соответствии с CC:'); //числа в любую сс z:=0; while s[1]='0' do delete(s,1,1); for i:=1 to length(s) do z:=z*m+pos(s[i],digit)-1; //перевод любой сс в str:=''; repeat str:=digit[(z mod k)+1]+str; z:=z div k; until z=0; end; begin writeln('из какой сс'); readln(m); writeln('число'); readln(k); writeln('в какую сс'); readln(s); perevod(m, k ,s ); end.
man integer, andsa string? - Igorsandkmixed inReadLn- this is the first error. Two recommendations: learn to use the debugger, removeWriteLnfrom theperevod- the dialogue with the user should occur before theperevodcall. - Igor