Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit unitMain;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm2 = class(TForm)
- Button1: TButton;
- cmbJumlahKartu: TComboBox;
- Label1: TLabel;
- Label2: TLabel;
- edMax: TEdit;
- edLokasi: TEdit;
- procedure Button1Click(Sender: TObject);
- private
- function pangkat(x, y: integer): integer;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form2: TForm2;
- implementation
- {$R *.dfm}
- function TForm2.pangkat(x, y: integer): integer;
- begin
- if (y = 1) then
- Result := x
- else if (y = 0) then
- Result := 1
- else
- Result := x * pangkat(x, y - 1);
- end;
- procedure TForm2.Button1Click(Sender: TObject);
- var
- i, x: integer;
- jmlKartu: integer;
- maxAngka: integer;
- mulai, akhir: integer;
- list: TStringList;
- begin
- i := 1;
- jmlKartu := StrToIntDef(cmbJumlahKartu.Text, 7);
- maxAngka := StrToIntDef(edMax.Text, 100);
- list := TStringList.Create;
- while i <= jmlKartu do
- begin
- mulai := pangkat(2, i-1);
- akhir := mulai;
- list.Clear;
- list.Add(VarToStr(mulai));
- while akhir <= maxAngka do
- begin
- x := 1;
- while x < mulai do
- begin
- Inc(akhir, 1);
- if akhir <= maxAngka then
- list.Add(VarToStr(akhir));
- Inc(x);
- end;
- Inc(akhir, mulai + 1);
- if akhir <= maxAngka then
- list.Add(VarToStr(akhir));
- end;
- Inc(i);
- list.SaveToFile(edLokasi.Text + '\radar_' + varToStr(i-1) + '.txt');
- Application.ProcessMessages;
- Caption := 'Proses file ke-' + VarToStr(i-1);
- end;
- Caption := 'Proses Selesai';
- list.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement