Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure Button4Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- function mocnina(a:integer):integer; //a: parameter funkcie
- begin
- //mocnina:=a*a;
- result:=a*a; //výsledok ulož do funkcie
- end;
- function max(a,b:integer):integer;
- begin
- if a>b then result:=a else result:=b;
- end;
- function parneneparne(a:integer):string;
- begin
- if a mod 2 = 0 then result:='Číslo je párne' else result:='Číslo je nepárne';
- end;
- function cifra(a:char):boolean;
- begin
- if (a>='0') and (a<='9') then
- result:=true
- else
- result:=false;
- end;
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- a:integer;
- begin
- a:=StrToInt(Edit1.Text);
- //mocnina(a); //Tento riadok nie je potrebný
- showmessage(inttostr(mocnina(a)));
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var
- a,b:integer;
- begin
- a:=StrToInt(Edit1.Text);
- b:=StrToInt(Edit2.Text);
- //max(a,b);
- showmessage(inttostr(max(a,b)));
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- a:integer;
- begin
- a:=StrToInt(Edit1.Text);
- Showmessage(parneneparne(a));
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- var
- a:char;
- begin
- a:=Edit1.Text[1];
- if cifra(a) then
- showmessage('Je to cifra') else showmessage ('Je to text');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement