(num[i]>'9') then goto e;
if system=8 then if (num[i]>'9') then goto e;
if system=10 then if (num[i]>'9') then goto e;
end;goto ok;
e:begin gotoxy(24,13);write(' ');
gotoxy(35,16);
textcolor(red);
write('Недопустиме число ');
end;
ok:end;
procedure convert_to_10(system:integer);
var num_out,num:string;
val_num,i,count:longint;
sum:real;
code,y:integer;
ch:char;
label m1;
begin
repeat
init;y:=6;
max_cursor;
textcolor(white);textbackground(0);
for i:=1 to 14 do begin
gotoxy(22,y);inc(y);write(' ');
end;
ramka(21,5,55,18);
textcolor(0);textbackground(green);
gotoxy(24,7);write('Введўть число в ',system,'-ўй системў:');
gotoxy(24,11);write(' Число в 10-ўй системў рўвне:');
gotoxy(24,16);write(' Помилка:');
textcolor(white);textbackground(white);
gotoxy(24,9);write(' ');
gotoxy(24,13);write(' ');
gotoxy(34,16);write(' ');
gotoxy(25,9);textcolor(0);textbackground(white);
readln(num);
num_out:='';
sum:=0;
count:=length(num);
for i:=0 to length(num) do begin
num[i]:=upcase(num[i]);
if num[i]='A' then sum:=sum+10*exp(count*ln(system));
if num[i]='B' then sum:=sum+11*exp(count*ln(system));
if num[i]='C' then sum:=sum+12*exp(count*ln(system));
if num[i]='D' then sum:=sum+13*exp(count*ln(system));
if num[i]='E' then sum:=sum+14*exp(count*ln(system));
if num[i]='F' then sum:=sum+15*exp(count*ln(system));
val(num[i],val_num,code);
if val_num<10 then sum:=sum+val_num*exp(count*ln(system));
count:=count-1;
end;
textcolor(0);textbackground(white);
gotoxy(25,13);write(sum:0:0);
check(system,num);
textbackground(0);
hide_cursor;
textcolor(green);
gotoxy(32,18);write(' ESC - ВИХЎД ');
ch:=readkey;
until ch=#27;
end;
procedure ten_to(system:integer);
const n=30;sys=10;
var a,f,x,y:longint;
b,d:real;
c:array[1..n] of byte;
code,i:integer;
num:real;
number:string;
ch:char;
begin
repeat
init;y:=6;
max_cursor;
for i:=0 to n do c[i]:=0;
for i:=1 to 14 do begin
gotoxy(22,y);inc(y);write(' ');
end;
ramka(21,5,55,18);
textbackground(green);textcolor(0);
gotoxy(24,7);write('Введўть число в 10-ўй системў:');
gotoxy(24,11);write(' Число в ',system,'-ўй системў рўвне: ');
gotoxy(24,16);write(' Помилка:');
textcolor(white);textbackground(white);
gotoxy(24,9);write(' ');
gotoxy(24,13);write(' ');
gotoxy(34,16);write(' ');
gotoxy(25,9);textcolor(0);textbackground(white);
readln(number);
i:=0;
val(number,num,code);
a:=trunc(num);
repeat
inc(i);
f:=trunc(a/system);
c[i]:=a-f*system;
a:=f;
until a<system;
inc(i);c[i]:=f;
gotoxy(25,13);
textcolor(0);textbackground(white);
repeat
if c[i]=10 then write('A');
if c[i]=11 then write('B');
if c[i]=12 then write('C');
if c[i]=13 then write('D');
if c[i]=14 then write('E');
if c[i]=15 then write('F');
if c[i]<10 then write(c[i]);
dec(i);
until i<1;
check(sys,number);
textbackground(0);
hide_cursor;
textcolor(green);
gotoxy(32,18);write(' ESC - ВИХЎД ');
ch:=readkey;
until ch=#27;
end;
begin
end.
Тест проводився на робочій станції з наступною конфігурацією:
- Pentium 166
- 32 Mb RAM
- SyncMaster 17Glsi
- S3 Trio64V+
- Windows 95
У результаті тестів були отримані наступні результати: