uses crt; var a,b,c:real; begin clrscr; write(‘Nhap a: ‘); readln(a); write (‘Nhap b: ‘); readln(b); write(‘Nhap c: ‘); readln(c); if ((a+b)>c) and ((b+c)>a) and ((a+c)>b) then writeln(a:4:2,’,’,b:4:2,’,’,c:4:2, ‘ la ba canh cua tam giac’) else writeln(a:4:2,’,’,b:4:2,’,’,c:4:2, ‘ khong phai la ba canh cua tam giac’); readln end.
progam ban_tu_chon;
uses crt;
var a,b,c :real;
BEGIN
clrscr;
write(‘nhap canh a thu nhat’); Read(a);
write(‘nhap canh b thu hai:’); Readln(b);
write(‘nhap canh c thu ba’); Readln(c);
if (a>=b+c) or (b>=c+a) or (c>=a+b) then write(‘ba canh tren khong phai cua mot tam giac’)
else
if (a=b) or (b=c) or (c=a) then write(‘tam giac tren la tam giac can’);
else
if a=b=c then write(‘tam giac tren la tam giac deu’)
else
if (a*a=b*b+c*c) or (b*b=c*c+a*a) or (c*c=a*a+b*b) then write(‘tam giac tren la tam giac vuong’);
readln;
END.
Xin hay nhất
ví dụ ba số a, b, c bất kỳ
ta có:
uses crt;
var a,b,c:real;
begin
clrscr;
write(‘Nhap a: ‘); readln(a);
write (‘Nhap b: ‘); readln(b);
write(‘Nhap c: ‘); readln(c);
if ((a+b)>c) and ((b+c)>a) and ((a+c)>b) then
writeln(a:4:2,’,’,b:4:2,’,’,c:4:2, ‘ la ba canh cua tam giac’)
else
writeln(a:4:2,’,’,b:4:2,’,’,c:4:2, ‘ khong phai la ba canh cua tam giac’);
readln
end.