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.

#include <bits/stdc++.h>
using namespace std;
long long a,b;
//chuongtrinhcon
long long gcd(long long a,long long b)
{
    if (b==0) return(a);
    return gcd(b,a%b);
}
//chuongtrinhchinh
int main()
{
    cin>>a>>b;
    if ((a>0 && b>0) or (a<0 && b<0)) cout<<a/gcd(a,b)<<" "<<b/gcd(a,b);
    else cout<<"-"<<-a/gcd(-a,b)<<" "<<b/gcd(-a,b);
    return 0;
}

 

11 tháng 3 2022

bằng free pascal chị

 

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.

3 tháng 4 2023

program Tong_Phan_So;

var

     tu_so1, mau_so1, tu_so2, mau_so2, tu_so_tong, mau_so_tong, ucln: integer;

begin

     write('Nhap tu so phan so 1: ');

     readln(tu_so1);

     write('Nhap mau so phan so 1: ');

     readln(mau_so1);

     write('Nhap tu so phan so 2: ');

     readln(tu_so2);

     write('Nhap mau so phan so 2: ');

     readln(mau_so2);

     tu_so_tong := tu_so1 * mau_so2 + tu_so2 * mau_so1;

     mau_so_tong := mau_so1 * mau_so2;

     ucln := gcd(tu_so_tong, mau_so_tong);

     tu_so_tong := tu_so_tong div ucln;

     mau_so_tong := mau_so_tong div ucln;

     writeln('Tong hai phan so la: ', tu_so_tong, '/', mau_so_tong);

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.

Đề thiếu rồi bạn

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.

16 tháng 11 2021

uses crt;

var a,b:real;

begin

clrscr;

readln(a,b);

writeln(2*(a+b):4:2);

writeln(a*b:4:2);

readln;

end.

16 tháng 11 2021

Program Chu_nhat; uses crt;

Var a, b, S, CV: real;

Begin    

 Write('Nhap chieu dai:'); readln(a);      

Write('Nhap chieu rong:'); readln(b);  

   S := a*b;      

CV := (a+b)*2;    

 Writeln('Dien tich hinh chu nhat la:',S:3:2);  

   Writeln('Chu vi hinh chu nhat la:',CV:3:2);    

 readln;

end.

 

 

23 tháng 5 2022

Program chunhat;

uses crt;

var a,b,p,s:real;

begin

clrscr;

writeln('Nhap chieu dai va rong cua hinh chu nhat: ');

readln(a,b);

s:=a*b;
p:=(a+b)*2;

write('Chu vi hinh chu nhat la: ', p:1:2);

writeln;

write('Dien tich hinh chu nhat la: ', s:1:2);

readln;

end.
 

Kết quả: 

24 tháng 10 2021

#include <bits/stdc++.h>

using namespace std;

double a,b,c,p;

int main()

{

cin>>a>>b>>c;

p=a+b+c;

cout<<fixed<<setprecision(2)<<p;

return 0;

}