как составить таблицу сложения и умножения для однозначных чисел девятеричной системы счисления?
Answers & Comments
And42
Если на паскале, то как-то так: function ToNine(number : integer) : integer; const sist = 9; var res, umn : integer; begin res := 0; umn := 1; while number > 0 do begin res := (number mod sist) * umn + res; number := number div sist; umn := umn * 10; end; ToNine := res; end;
var i : integer; begin for i := 1 to 8 do writeln(i, ' + ', i, ' = ', ToNine(i + i)); for i := 1 to 8 do writeln(i, ' * ', i, ' = ', ToNine(i * i)); end.
Answers & Comments
function ToNine(number : integer) : integer;
const
sist = 9;
var
res, umn : integer;
begin
res := 0;
umn := 1;
while number > 0 do
begin
res := (number mod sist) * umn + res;
number := number div sist;
umn := umn * 10;
end;
ToNine := res;
end;
var
i : integer;
begin
for i := 1 to 8 do
writeln(i, ' + ', i, ' = ', ToNine(i + i));
for i := 1 to 8 do
writeln(i, ' * ', i, ' = ', ToNine(i * i));
end.