1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
| unit U_1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Label2: TLabel;
BitBtn3: TBitBtn;
Panel1: TPanel;
Label3: TLabel;
Edit3: TEdit;
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Label3Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure Label1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure MsgBox(Capt, Msg: string);
begin
MessageBox(0, PChar(Msg), PChar(Capt), MB_right);
end;
function Cchper(n,r : integer) : string;
var
per1 : string;
const
digit:string[16] = '0123456789ABCDEF';
begin
per1 := '';
repeat
per1 := digit[(n mod r)+1] + per1;
n := n div r;
until n = 0;
result := per1;
end;
function Dchper(n,r,z: integer) : string;
var
per1,s,s1: string;
i,j: integer;
const
digit:string[16] = '0123456789ABCDEF';
begin
s1:=inttostr(n);
s:='1';
for j:=1 to length(s1) do
s:=s+'0';
per1 := '';
for i:=1 to z do begin
per1 := digit[((n*r)mod strtoint(s))+1] + per1;
n := n div strtoint(s);
result := per1;
end;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'0'..'9':
else key:=#0;
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'0'..'9',',','-':
else key:=#0;
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var Cch,Dch,x,minus,i,k,P,a,z,s11:integer;
s,C,D,CchP,DchP,s1:string;
begin
s:=Edit1.Text;
s1:=Edit2.Text;
s11:=strtoint(Edit2.Text);
z:=strtoint(Edit3.Text);
minus:=pos('-',s);
if minus = 1 then begin k:=1; Delete(s,1,1);end;
MsgBox('óäàëèëè ïåðâûé - ', s);
for a:= 1 to length(s) do begin
for i:= 1 to length(s) do
if s[i]='-' then delete(s,i,1);end;
MsgBox('óäàëèëè âñå - ', s);
for a:= pos(',',s) to length(s) do begin
for i:= (pos(',',s)+1) to length(s) do
if s[i]=',' then delete(s,i,1);end;
MsgBox('óäàëèëè âñå ëèøíèå, ', s);
if pos(',',s)=0 then
begin MsgBox('Ï',inttostr(a));
C:=copy(s,1,length(s)); MsgBox('Öåëàÿ ÷àñòü, íåò äðîáíîé', C);
D:='0'; MsgBox('D',D);
end
else
begin
C:=copy(s,1,pos(',',s)-1);
MsgBox('Öåëàÿ ÷àñòü', C);
D:=copy(s,pos(',',s)+1,length(s)-pos(',',s));
MsgBox('Äðîáíàÿ ÷àñòü', D);
end;
if (length(s)=0) or (length(s1)=0) or (s11>16) then
MsgBox('ÎØÈÁÊÀ! ','Íå ïðàâèëüíî ââåäåíî ÷èñëî èëè îñíîâàíèå')
else
begin
Cch:=strtoint(C); MsgBox('CCC',inttostr(Cch));
Dch:=strtoint(D); MsgBox('DDDD',inttostr(Cch));
P:=strtoint(Edit2.Text); MsgBox('Îñíîâàíèå',inttostr(P));
CchP:=Cchper(Cch,P);
DchP:=Dchper(Dch,P,z);
MsgBox('Ïåðåâîä öåëîé',CchP);
MsgBox('Ïåðåâîä äðîáíîé',CchP);
MsgBox('Îòâåò','×èñëî êîòîðîå ââåëè'+Edit1.Text+#13#10+
'×èñëî êîòîðîå ïåðåâîäèëè'+s+#13#10+
'Îòâåò'+CchP+','+DchP+':)');
end;
end;
end. |