Ghost
Решение задачи:
Код:
function MM(m1,m2:integer):string;
var
i,k,l:integer;
s,m,b,d,dudu:string;
ok:boolean;
begin
s:=FloatToStr(m1/m2);
if pos(',',s)<=0 then
begin
Result:=s;
exit;
end;
b:=copy(s,1,pos(',',s)-1);
delete(s,1,pos(',',s));
for i:=1 to Length(s) do
begin
for k:=1 to Length(s)-i do
begin
m:='';
d:=s;
delete(d,1,i-1);
m:=copy(s,i,k);
delete(d,1,Length(m));
if pos(m,d)>0 then
begin
ok:=true;
delete(d,(length(d) div Length(m))*Length(m),length(d));
for l:=1 to (length(d) div Length(m)) do
begin
dudu:=copy(d,(l*Length(m))-(Length(m)-1),Length(m));
if (Length(m)<=Length(d)-l*Length(m)) and (dudu<>m) then
begin
ok:=false;
break;
end;
end;
if ok then
begin
Result:=b+','+copy(s,1,i-1)+'('+m+')';
exit;
end;
end;
end;
end;
end;
ф-ия, где m1 и m2 - числитель и знаменатель дроби...
В каком ты там вузе?