Advertisement
AntoSVK

funkcie - max, mocnina

Nov 2nd, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.86 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Edit1: TEdit;
  13.     Edit2: TEdit;
  14.     Button2: TButton;
  15.     Button3: TButton;
  16.     Button4: TButton;
  17.     procedure Button4Click(Sender: TObject);
  18.     procedure Button3Click(Sender: TObject);
  19.     procedure Button2Click(Sender: TObject);
  20.     procedure Button1Click(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.   function mocnina(a:integer):integer; //a: parameter funkcie
  32.     begin
  33.       //mocnina:=a*a;
  34.     result:=a*a;     //výsledok ulož do funkcie
  35.     end;
  36.  
  37.   function max(a,b:integer):integer;
  38.     begin
  39.       if a>b then result:=a else result:=b;
  40.     end;
  41.  
  42.   function parneneparne(a:integer):string;
  43.     begin
  44.       if a mod 2 = 0 then result:='Číslo je párne' else result:='Číslo je nepárne';
  45.  
  46.     end;
  47.  
  48.   function cifra(a:char):boolean;
  49.     begin
  50.       if (a>='0') and (a<='9') then
  51.       result:=true
  52.         else
  53.       result:=false;
  54.     end;
  55.  
  56. {$R *.dfm}
  57.  
  58. procedure TForm1.Button1Click(Sender: TObject);
  59. var
  60. a:integer;
  61. begin
  62. a:=StrToInt(Edit1.Text);
  63. //mocnina(a);        //Tento riadok nie je potrebný
  64. showmessage(inttostr(mocnina(a)));
  65.  
  66. end;
  67.  
  68. procedure TForm1.Button2Click(Sender: TObject);
  69. var
  70. a,b:integer;
  71. begin
  72. a:=StrToInt(Edit1.Text);
  73. b:=StrToInt(Edit2.Text);
  74. //max(a,b);
  75. showmessage(inttostr(max(a,b)));
  76.  
  77. end;
  78.  
  79. procedure TForm1.Button3Click(Sender: TObject);
  80. var
  81. a:integer;
  82. begin
  83. a:=StrToInt(Edit1.Text);
  84. Showmessage(parneneparne(a));
  85. end;
  86.  
  87. procedure TForm1.Button4Click(Sender: TObject);
  88. var
  89. a:char;
  90. begin
  91. a:=Edit1.Text[1];
  92. if cifra(a) then
  93. showmessage('Je to cifra') else showmessage ('Je to text');
  94. end;
  95.  
  96. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement