[ 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.
[ Kupushich @ 19.06.2006. 11:18 ] @
Sad sam ga riješila na drugi način, ali ni to ne radi, MOLIM VAS, POMOĆ!!!!
Evo...

var b,n,i,j:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
for i:=2 to a do
if (a mod i =0) and (b mod i =0) then begin
repeat
a:=b div i; b:=n div i;
until (a mod i<>0) or (b mod i<>0);end;
label4.caption:=inttostr(a);
label6.caption:=inttostr(b);
end.
[ Whois @ 19.06.2006. 12:15 ] @
Code:

for i:= a downto 2 do
  if (a mod i=0) and (b mod i=0) then
    begin
      a:=a div i;
      b:=b div i;
    end;