program dvt;
uses
crt;
var
tr: array [0..50] of integer;
d: longint;
i, k: integer;
begin
writeln('Введите десятичное число:');
readln(d);
i := 0;
while d > 2 do
tr[i] := d mod 3;
d := d div 3;
i := i + 1;
end;
tr[i] := d;
writeln('Получилось троичное число:');
for k := i downto 0 do
write(tr[k]);
readln;
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
program dvt;
uses
crt;
var
tr: array [0..50] of integer;
var
d: longint;
var
i, k: integer;
begin
writeln('Введите десятичное число:');
readln(d);
i := 0;
while d > 2 do
begin
tr[i] := d mod 3;
d := d div 3;
i := i + 1;
end;
tr[i] := d;
writeln('Получилось троичное число:');
for k := i downto 0 do
write(tr[k]);
readln;
end.