Advertisement
Guest User

aaaa

a guest
Oct 24th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.15 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Edit1: TEdit;
  12.     Edit2: TEdit;
  13.     Label1: TLabel;
  14.     Button1: TButton;
  15.     Label2: TLabel;
  16.     procedure Edit1Change(Sender: TObject; var key: char);
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.dfm}
  30.  
  31.  
  32. procedure funkcja(x:integer);
  33. var i, a:integer;
  34.  
  35. begin
  36.  
  37. i := 1;
  38. a := 0;
  39. while(i <= x/2) do
  40. begin
  41.   if (x mod i = 0) then a:= a + i;
  42.  
  43.   i:= i + 1;
  44. end;
  45.    if x = a then writeln (x);
  46.  
  47. end;
  48.  
  49. procedure TForm1.Button1Click(Sender: TObject);
  50. var A, B, krok:integer;
  51. begin
  52. A:= StrtoInt(Edit1.Text);
  53. B:= StrtoInt(Edit2.Text);
  54. for krok := A to B do
  55. begin
  56. Label2.Caption := InttoStr(funkcja(A));
  57. A := A + 1;
  58. end;
  59.  
  60. end;
  61.  
  62. procedure TForm1.Edit1Change(Sender: TObject; var key: char);
  63. begin
  64.  
  65. If Not (Key In ['1'..'9',#8,'.'])then Key:= #0;
  66.  
  67. end;
  68.  
  69.  
  70.  
  71.  
  72. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement