[ Kupushich @ 19.06.2006. 10:36 ] @
U delphiju imam zadatak skratiti razlomak (graficko sucelje), i ja znam kako to otprilike ide ali ne znam sve... pa ako moze pomoc... evo ovo sto sam ja napravila dosad(ima gresaka ali ne znam ispraviti...) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; //za unos brojnika Edit2: TEdit; //za unos nazivnika Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; //treba ispisati skraceni brojnik Label5: TLabel; Label6: TLabel; //treba ispisati skraceni nazivnik Button1: TButton; Button2: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button2Click(Sender: TObject); begin Halt; end; procedure TForm1.Button1Click(Sender: TObject); var x,y,a,b,i:integer; begin a:=strtoint(edit1.text); b:=strtoint(edit2.Text); if a<b then begin x:=a; y:=b; end else begin y:=a; x:=b; end; for i:= 1 to x do if (x mod i=0) and (y mod i=0) then d:=n; label4.Caption:= floattostr(strtofloat(a/d)); label6.Caption:= floattostr(strtofloat(b/d)); end; end. |