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:
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
{変数宣言}
var
nisin : array[1..16] of Integer;
jyu,i : Integer;
begin
{入力}
jyu := StrToInt(Edit1.Text);
{変換}
for i:=1 to 16 do begin
nisin[i] := jyu mod 2;
jyu := Trunc(jyu / 2);
end;
{表示}
Label1.Caption :='';
for i:=16 downto 1 do begin
Label1.Caption := Label1.Caption + IntToStr(nisin[i]);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Button1.Caption := '変換';
Button1.Default := True;
Edit1.Text := '';
Edit1.TabOrder := 0;
Label1.Caption := '';
Label1.Color := clWhite;
Label1.AutoSize := False;
end;
end.
|