Bài 19. Thư viện chương trình con chuẩn

Thần thú bành
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 5 2021 lúc 9:51

Bài 2: 

uses crt;

var a,b,c,p,s,am,bn,cp:real;

begin

clrscr;

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

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

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

if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then

begin

writeln('Day la ba canh trong mot tam giac vuong');

p:=(a+b+c)/2;

s:=sqrt(p*(p-a)*(p-b)*(p-c));

writeln('Dien tich tam giac la: ',s:4:2);

am:=sqrt(2*(sqr(b)+sqr(c))-sqr(a))/4;

bn:=sqrt(2*(sqr(a)+sqr(c))-sqr(b))/4;

cp:=sqrt(2*(sqr(a)+sqr(b))-sqr(c))/4;

writeln('Do dai duong trung tuyen ung voi canh a la: ',am:4:2);

writeln('Do dai duong trung tuyen ung voi canh b la: ',bn:4:2);

writeln('Do dai duong trung tuyen ung voi canh c la: ',cp:4:2);

end

else writeln('Day khong la ba canh trong mot tam giac');

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
19 tháng 5 2021 lúc 9:53

Bài 3: 

uses crt;

var a,b,ucln,bcnn,i:integer;

begin

clrscr;

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

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

ucln:=1;

if a<b then 

begin

for i:=1 to a do 

  if (a mod i=0) and (b mod i=0) then 

begin

if ucln<i then ucln:=i;

end;

end

else begin

for i:=1 to b do 

  if (a mod i=0) and (b mod i=0) then 

begin

if ucln<i then ucln:=i;

end;

end;

writeln('Uoc chung lon nhat la: ',ucln);

bcnn:=a*b;

for i:=a*b-1 downto 1 do 

  if (i mod a=0) and (i mod b=0) then

begin

if bcnn>i then bcnn:=i;

end;

writeln('Boi chung nho nhat la: ',bcnn);

readln;

end.

Bình luận (0)
tri123
6 tháng 8 2021 lúc 19:46

Bài 2: 

uses crt;

var a,b,c,p,s,am,bn,cp:real;

begin

clrscr;

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

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

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

if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then

begin

writeln('Day la ba canh trong mot tam giac vuong');

p:=(a+b+c)/2;

s:=sqrt(p*(p-a)*(p-b)*(p-c));

writeln('Dien tich tam giac la: ',s:4:2);

am:=sqrt(2*(sqr(b)+sqr(c))-sqr(a))/4;

bn:=sqrt(2*(sqr(a)+sqr(c))-sqr(b))/4;

cp:=sqrt(2*(sqr(a)+sqr(b))-sqr(c))/4;

writeln('Do dai duong trung tuyen ung voi canh a la: ',am:4:2);

writeln('Do dai duong trung tuyen ung voi canh b la: ',bn:4:2);

writeln('Do dai duong trung tuyen ung voi canh c la: ',cp:4:2);

end

else writeln('Day khong la ba canh trong mot tam giac');

readln;

học tốt nha b

Bình luận (0)
Giagg
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:03

uses crt;

var a,b,c,d:integer;

begin

clrscr;

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

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

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

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

if (b<>0) and (d<>0) then writeln(a/b+c/d:4:2)

else writeln('Vui long nhap lai');

readln;

end.

Bình luận (0)
Ng Ọc
Xem chi tiết