Program PRACT14; Uses CRT; Var m, n, p, q: LongInt;
Function NOD(x, y: LongInt): LongInt; Begin If (x <> 0) then NOD := NOD(y mod x, x) Else NOD := y; End;
Begin ClrScr; Repeat Write('Введите числа m и n: '); ReadLn(m,n); Writeln; Until (m > 0) and (n > 0);
q := NOD(m, n); p := m div q; q := n div q;
Writeln('Найдены числа p и q'); Writeln('p = ',p,#13#10,'q = ',q); Writeln(m,'/',n,' = ',p,'/',q); ReadKey; End.
Источник: |