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.

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.

#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.

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.

13 tháng 12 2020

uses crt;

var a,b:integer; {------------------------chuong-trinh-con-tim-uoc-chung-lon-nhat-cua-a-va-b----------------------}

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

var i,uc:integer;

begin

   uc:=1;

   if x<y then

      begin

         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

           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 so a='); readln(a);

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

a:=a div ucln(a,b);

b:=b div ucln(a,b);

writeln('Phan so toi gian la: ',a,'/',b);

readln;

end.

13 tháng 12 2020
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;

}

Đề thiếu rồi bạn