1

Topic: To rewrite the program with PascalABC on With ++

Help to rewrite, please, the program with PascalABC on With ++.....

function outten (K:longint; s:integer):string;
var sum:string;
const A:string [16] = ' 0123456789ABCDEF ';
begin
sum: = ";
while K <> 0 do
begin
sum: = A [(K mod s) +1] +sum;
K: = K div s
end;
outten: = sum
end;

2

Re: To rewrite the program with PascalABC on With ++

If I correctly understood that such string, mod and div,

char outten (LONG K, int s)
{
char sum = 0;
const char* A = "0123456789ABCDEF";
while (K)
{
sum + = A [K % s + 1];
K / = s;
}
return sum;
}

3

Re: To rewrite the program with PascalABC on With ++

Cerebrum wrote:

sum + = A [K % s>>> + 1 <<<];

Pascal is very long time ago forgotten, but I suspect that array cells there  with 1, and in / ++ with 0, i.e. +1 here the superfluous.
It

char sum = 0;

In an initial variant was sum:string

4

Re: To rewrite the program with PascalABC on With ++

There is a function itoa () which does too most.

5

Re: To rewrite the program with PascalABC on With ++

Dima T wrote:

It

Me confused

const A:string [16] = ' 0123456789ABCDEF ';

If string is a line the array from 16 lines turns out that here and everyone is equal ' 0123456789ABCDEF ' or only one? Therefore decided that speech is faster about characters, than lines.
Here therefore never also did not want to learn this pascal, it is enough to look only at a difference in literary trash volume to understand why. As someone correctly noted: language With is created for convenience of the programmer, and Pascal - for convenience of the compiler.
It is good, when there are those who you correct smile

6

Re: To rewrite the program with PascalABC on With ++

Cerebrum;
Matter is not in pascal, and in banal transfer in N-dimensional numeration system. Your error that you did not understand what exactly this task dares.