вот исходный текст:
Program Radix1;
uses crt;
var
ch : char;
continue : boolean;
radix,i : integer;
number : real;
int,decimal : integer;
function enter_radix : integer;
begin
repeat
clrscr;
writeln('Input radix ');
readln(radix);
until (radix>=2) and (radix<=16);
enter_radix:= radix;
end;
function get_val(c:char) : integer;
begin
if (c>='0') and (c<='9')
then get_val := ord© - ord('0')
else if (c>='a') and (c<='f')
then get_val:= ord©-ord('a')+10
else if(c>='A') and (c<='F')
then get_val:= ord©-ord('A')+10
else
get_val:= - 10000;
end;
function in_radix(radix: integer; c: char): boolean;
Var
x : integer;
Begin
x:= get_val©;
if(radix<=abs(x)) then in_radix:= false
else in_radix:= true;
end;
function get_char(x : integer) : char;
begin
if(x<10)then get_char:= chr(x+ord('0'))
else get_char:= chr(x-10+ord('A'));
end;
function enter_digit(radix : integer; Var int, decimal : integer) : boolean;
Var str : string[21];
z : char;
i,l : integer;
dot_flag : boolean;
begin
dot_flag:= false;
int:= 0;
decimal:= 0;
writeln('Input number with radix = ',radix);
readln(str);
l:=length(str);
writeln(int);
for i:= 1 to l do
begin
if(str[i]='.' ) then
begin
if dot_flag then
begin
enter_digit:=false;
exit;
end
else
dot_flag:= true;
end
else if in_radix (radix, str[i]) then
begin
if dot_flag then
begin
decimal:= decimal*radix+get_val(str[i]);
end
else
begin
int:= int*radix+get_val(str[i]);
end;
end
else
begin
enter_digit:= false;
exit;
end;
end;
enter_digit:= true;
end;
procedure print_number(radix : integer; num : integer);
Var c : char;
i,j : integer;
out : string[20];
q,r : integer;
begin
for i:=1 to 20 do out[i]:=' ';
repeat
q:=num div radix;
r:=num mod radix;
c:= get_char®;
out[i]:= c;
i:= i-1;
num:= q;
until num = 0;
i:= 1;
while(out[i]=' ') do i:=i+1;
for j:= i to 20 do write (out[j]);
end;
procedure startup_init;
Var
i,j : integer;
c : char;
begin
textmode (co80);
clrscr;
textcolor(0);
textbackground(10);
clrscr;
gotoxy (11,19);
for i:=11 to 70 do write (#219);
for i:=7 to 19 do
begin
gotoxy(71,i);
writeln(#219);
END;
window (10,6,70,17);
textbackground(blue);
textcolor(0);
clrscr;
window(10,6,70,21);
write(#218);
for i:=11 to 69 do write (#196);
write(#191);
for i:=2 to 12 do
begin
gotoxy(1,i);
write(#179);
gotoxy (61,i);
write(#179);
end;
write(#192);
gotoxy(2,13);
for i:=11 to 69 do write (#196);
write(#217);
window(12,7,68,12);
textcolor(lightgreen);
end;
begin
startup_init;
ch:='r';
while ch='r' do
begin
radix:=enter_radix;
repeat
clrscr;
continue:=enter_digit(radix,int,decimal);
until continue;
radix:=enter_radix;
clrscr;
writeln('Nuber in radix = ',radix);
print_number(radix,int);
if(decimal<>0) then
begin
write('.');
print_number(radix,decimal);
end;
gotoxy(1,4);
writeln('Press r to repeat');
writeln('and other kay to exit');
ch:=readkey;
end;
end.
Сообщение отредактировано: Kubus -