K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.

22 tháng 10 2021

uses crt;

var i:integer;

begin

clrscr;

for i:=0 to 9999 do 

  if trunc(sqrt(i))=sqrt(i) then write(i:4);

readln;

end.

uses crt;

var a,b:integer;

{-----------------chuong-trinh-con-------------------}

function ucln(x,y:integer):integer;

var i,uc:integer;

begin

if x<y then 

begin

uc:=1;

for i:=1 to x do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end

else begin

uc:=1;

for i:=1 to y do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end;

ucln:=uc;

end;

{--------------------------chuong-trinh-chinh------------------------}

begin

clrscr;

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));

readln;

end.

5 tháng 3 2022

Dạ pascal được không ạ, 

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.

uses crt;

var a,b,x,y:integer;

//chuongtrinhcon

function ucln(var a,b:integer):integer;

var r:integer;

begin

while b>0 do

begin

r:=a mod b;

a:=b;

b:=r;

end;

ucln:=a;

end;

//chuongtrinhchinh

begin

clrscr;

readln(a,b);

x:=a;

y:=b;

if (x>0) and (y>0) then writeln(x div ucln(a,b),' ',y div ucln(a,b));

if (x<0) and (y<0) then 

begin

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end; 

if (x<0) and (y>0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

if (x>0) and (y<0) then 

begin

write('-');

x:=abs(x);

y:=abs(y);

a:=abs(a);

b:=abs(b);

writeln(x div ucln(a,b),' ',y div ucln(a,b));

end;

readln;

end.