вот пробуй. делалось в delphi 3. не доделано
есть рабочая в досе
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit4: TEdit;
Label5: TLabel;
Button1: TButton;
Memo1: TMemo;
CheckBox1: TCheckBox;
edit1: TComboBox;
edit3: TComboBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
function stepen(num,step:integer):integer;
var i,num1:integer;
begin
num1:=1;
for i:=1 to step do
num1:=num1*num;
stepen:=num1;
end;
function perev10(x:integer):string;
begin
case x of
10: result:='A';
11: result:='B';
12: result:='C';
13: result:='D';
14: result:='E';
15: result:='F';
16: result:='G';
17: result:='H';
18: result:='I';
19: result:='J';
20: result:='K';
END;
end;
function perev16(x:char):integer;
begin
case x of
'A','a': result:=10;
'B','b': result:=11;
'C','c': result:=12;
'D','d': result:=13;
'E','e': result:=14;
'F','f': result:=15;
'G','g': result:=16;
'H','h': result:=17;
'I','i': result:=18;
'J','j': result:=19;
'K','k': result:=20;
else result:=strtoint(x);
end;
end;
function drob(ur:real):string;
var
i:integer;
c,s:string;
begin
c:=''; s:=floattostr(ur);
i:=0;
while s[i]<> ',' do inc(i);
while i<= length(s) do
begin
c:=c+s[i];
inc(i);
end;
result:=c;
end;
procedure TForm1.Button1Click(Sender: TObject);
var b,chislo,i,x,a:integer;
tab,xxx:string;
begin
a:=strtoint(edit3.text);
b:=0;tab:='';
memo1.lines.Clear;
xxx:=':';
for i:=1 to length(edit2.text) do
//if (edit2.text[i]=',') then checkbox1.Checked:=true;
{if checkbox1.Checked then
begin
memo1.lines.add(edit2.text+'('+edit1.text+') To 0 , X ('+edit3.text+')');
b:=length(edit2.text)-2;
a:=strtoint(edit3.text);
r:=strtofloat(edit2.text);
i:=0;
while (i<=b) do
begin
inc(i);
r:=r*a;
if r<1 then xxx:=xxx+'0';
xxx:=xxx+ floattostr(r-strtofloat(drob(r)));
ur:=r-strtofloat(drob(r));
r:=r-ur;
end;
memo1.lines.add(xxx);
end
else begin}
memo1.lines.add(edit2.text+'('+edit1.text+') To X ('+edit3.text+')');
memo1.lines.add('');
if edit1.text<>'10' then begin
for i:=1 to length(edit2.text) do
begin {перевод в десятичную}
b:=b+perev16(edit2.text[i])*stepen(strtoint(edit1.text),length(edit2.text)-i);
memo1.lines.add(edit2.text[i]+'*'+ edit1.text+'^'+ inttostr(length(edit2.text)-i)+'+');
end;
memo1.lines.add(' ='+inttostr(b));
end else b:=strtoint(edit2.text);;
{перевод в заданную сс}
chislo:= strtoint(edit3.text);
if chislo<>10 then begin
while a>=chislo do begin
showmessage(inttostr(a));
a:=b div chislo;
x:=b-a* chislo;
if (strtoint(edit3.text)>10) and(x>9)then xxx:=perev10(x)+xxx else xxx:=inttostr(x)+xxx;
tab:=tab+' ';
memo1.lines.add(tab+':'+inttostr(chislo)+'='+inttostr(a)+'('+inttostr(x)+')');
b:=a;
end;
if (strtoint(edit3.text)>10) and(a>9)then xxx:=perev10(a)+xxx else xxx:=inttostr(a)+xxx;
end else xxx:=inttostr(chislo);
edit4.text:=xxx;
memo1.lines.add('X='+ xxx);
end;
// end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Memo1: TMemo;
Panel1: TPanel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
begin
form2.close;
end;
end.