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. 

Closed due to the fact that off-topic participants Kromster , user194374, Denis Bubnov , Vadim Ovchinnikov , vp_arth 21 Feb '17 at 15:55 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kromster, Community Spirit, Denis Bubnov, Vadim Ovchinnikov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Why is m an integer, and s a string? - Igor
  • m - according to the task condition the number system in which there is a number, k - ss to which you need to translate, and s - the number that we need to translate, a string due to the fact that there may be a number in any system (ABC may appear, etc. .). - Arbron
  • one
    you have s and k mixed in ReadLn - this is the first error. Two recommendations: learn to use the debugger, remove WriteLn from the perevod - the dialogue with the user should occur before the perevod call. - Igor
  • And how are you going to get / see the result? - Alekcvp
  • Thank you comment @Igor helped, I really confused s and k! - Arbron

0