SHARE
TWEET

Radar Angka Generator

WISNUWIDIARTA Jan 20th, 2013 233 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. unit unitMain;
  3.  
  4. interface
  5.  
  6. uses
  7.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  8.   Dialogs, StdCtrls;
  9.  
  10. type
  11.   TForm2 = class(TForm)
  12.     Button1: TButton;
  13.     cmbJumlahKartu: TComboBox;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     edMax: TEdit;
  17.     edLokasi: TEdit;
  18.     procedure Button1Click(Sender: TObject);
  19.   private
  20.     function pangkat(x, y: integer): integer;
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form2: TForm2;
  28.  
  29. implementation
  30.  
  31. {$R *.dfm}
  32.  
  33. function TForm2.pangkat(x, y: integer): integer;
  34. begin
  35.   if (y = 1) then
  36.     Result := x
  37.   else if (y = 0) then
  38.     Result := 1
  39.   else
  40.     Result := x * pangkat(x, y - 1);
  41. end;
  42.  
  43. procedure TForm2.Button1Click(Sender: TObject);
  44. var
  45.   i, x: integer;
  46.   jmlKartu: integer;
  47.   maxAngka: integer;
  48.   mulai, akhir: integer;
  49.   list: TStringList;
  50. begin
  51.   i := 1;
  52.   jmlKartu := StrToIntDef(cmbJumlahKartu.Text, 7);
  53.   maxAngka := StrToIntDef(edMax.Text, 100);
  54.   list := TStringList.Create;
  55.   while i <= jmlKartu do
  56.   begin
  57.     mulai := pangkat(2, i-1);
  58.     akhir := mulai;
  59.     list.Clear;
  60.     list.Add(VarToStr(mulai));
  61.     while akhir <= maxAngka do
  62.     begin
  63.       x := 1;
  64.       while x < mulai do
  65.       begin
  66.         Inc(akhir, 1);
  67.         if akhir <= maxAngka then
  68.           list.Add(VarToStr(akhir));
  69.         Inc(x);
  70.       end;
  71.       Inc(akhir, mulai + 1);
  72.       if akhir <= maxAngka then
  73.           list.Add(VarToStr(akhir));
  74.     end;
  75.     Inc(i);
  76.     list.SaveToFile(edLokasi.Text + '\radar_' + varToStr(i-1) + '.txt');
  77.     Application.ProcessMessages;
  78.     Caption := 'Proses file ke-' + VarToStr(i-1);
  79.   end;
  80.   Caption := 'Proses Selesai';
  81.   list.Free;
  82. end;
  83.  
  84. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top