Lập chương trình nhập vào tọa độ 3 đỉnh A(Xa, Ya), B(Xb, Yb), C(Xc, Yc) của 1 tam giác
a, Tính Chu vi, Diện tích
b, Kiểm tra tính chất và cho biết đây là tam giác cân, đều hay vuông.
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;
double xa,ya,xb,yb,xc,yc,ab,ac,bc;
int main()
{
cin>>xa>>ya>>xb>>yb>>xc>>yc;
ab=(sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)));
ac=(sqrt((xa-xc)*(xa-xc)+(ya-yc)*(ya-yc)));
bc=(sqrt((xb-xc)*(xb-xc)+(yb-yc)*(yb-yc)));
p=(ab+bc+ac)/2;
s=sqrt(p*(p-ab)*(p-ac)*(p-bc));
cout<<"Dien tich la:"<<fixed<<setprecision(2)<<s<<endl;
cout<<"Duong cao ung voi dinh A la:"<<fixed<<setprecision(2)<<2*s/bc<<endl;
cout<<"Duong cao ung voi dinh B la:"<<fixed<<setprecision(2)<<2*s/ac<<endl;
cout<<"Duong cao ung voi dinh C la:"<<fixed<<setprecision(2)<<2*s/ab<<endl;
return 0;
}
var a,b,c,s,p: real;
begin
write('Nhap canh thu nhat: '); readln(a);
write('Nhap canh thu hai: '); readln(b);
write('Nhap canh thu ba: '); readln(c);
if (a+b>c) and (b+c>a) and (c+a>b) then
begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Chu vi tam giac la ',2*p:5:2, '(dvdd)');
writeln('Dien tich tam giac la: ',s:5:2, '(dvdt)');
if (a=b) and (b=c) then writeln('Day con la tam giac deu') else
if (a=b) or (b=c) or (c=a) then writeln('Day la tam giac can') else
if (a*a+b*b=c*c) or (b*b+c*c=a*a) or (c*c+a*a=b*b) then writeln('Day la tam giac vuong') else
writeln('Day la tam giac thuong');
if ((a=b) or (b=c) or (c=a)) and ((a*a+b*b=c*c) or (b*b+c*c=a*a) or (c*c+a*a=b*b)) then writeln('Day la tam giac vuong can')
end
else writeln(a:5:2,',',b:5:2,',',c:5:2,' khong la do dai mot tam giac');
end.
Viết Chương trình diện tích tứ giác ABCD khi biết tọa độ Điểm A(xA,yA); B(xB,yB); C(xC,yC); D(xD,yD)
const fi='tamgiac.dat';
fo='tamgiac.out';
var f1,f2:text;
a,b,c,d,e,f:array[1..100]of integer;
i,n,dem1,dem2,dem3:integer;
ab,bc,ac:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
readln(f1,a[i],b[i],c[i],d[i],e[i],f[i]);
dem1:=0;
dem2:=0;
dem3:=0;
for i:=1 to n do
begin
ab:=sqrt(sqr(a[i]-c[i])+sqr(b[i]-d[i]));
ac:=sqrt(sqr(a[i]-e[i])+sqr(b[i]-f[i]));
bc:=sqrt(sqr(c[i]-e[i])+sqr(d[i]-f[i]));
if (ab>0) and (ac>0) and (bc>0) and (ab+ac>bc) and (ab+bc>ac) and
(ac+bc>ab) then
begin
if (ab=ac) or (ac=bc) then inc(dem1);
if ((ab=ac) and (ab<>bc) and (ac<>bc)) then inc(dem2);
if ((ac=bc) and (bc<>ab) and (ac<>ab)) then inc(dem2);
if ((ac=bc) and (ac<>ab) and (bc<>ab)) then inc(dem2);
if sqr(ab)=sqr(ac)+sqr(bc) then inc(dem3);
if sqr(ac)=sqr(bc)+sqr(ab) then inc(dem3);
if sqr(bc)=sqr(ab)+sqr(ac) then inc(dem3);
end;
end;
writeln(f2,dem1);
writeln(f2,dem2);
writeln(f2,dem3);
close(f1);
close(f2);
end.
Câu 1:
uses crt;
var a,s,p:real;
begin
clrscr;
repeat
write('Nhap do dai canh hinh vuong:'); readln(a);
until a>0;
p:=4*a;
s:=sqr(a);
writeln('Chu vi hinh vuong la: ',p:4:2);
writeln('Dien tich hinh vuong la: ',s);
readln;
end.
Câu 2:
uses crt;
var a,b,t,s,h:real;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
t:=a+b;
h:=a-b;
s:=a*b;
writeln('Tong la: ',t:4:2);
writeln('Hieu la: ',h:4:2);
writeln('Tich la: ',s:4:2);
readln;
end.
Câu 3:
uses crt;
var a,b,c:real;
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
until (a>0) and (b>0) and (c>0);
if (a+b>c) and (a+c>b) and (b+c>a) then writeln('Day la ba canh trong mot tam giac')
else writeln('Day khong la ba canh trong mot tam giac');
readln;
end.
uses crt;
var xa,ya,xb,yb,xc,yc:integer;
ab,ac,bc,cv,p,s:real;
begin
clrscr;
write('Nhap toa do diem A:'); readln(xa,ya);
write('Nhap toa do diem B:'); readln(xb,yb);
write('Nhap toa do diem C:'); readln(xc,yc);
ab:=sqrt(sqr(xa-xb)+sqr(ya-yb));
ac:=sqrt(sqr(xa-xc)+sqr(ya-yc));
bc:=sqrt(sqr(xb-xc)+sqr(yb-yc));
if (ab+bc>ac) and (ab+ac>bc) and (ac+bc>ab) then
begin
cv:=ab+bc+ac;
p:=cv/2;
s:=sqrt(p*(p-ab)*(p-ac)*(p-bc));
writeln('Chu vi la: ',cv:4:2);
writeln('Dien tich la: ',dt:4:2);
kt:=0;
if (ab=ac) and (ab<>bc) and (ac<>bc) then kt:=1;
if (ac=bc) and (ac<>ab) and (bc<>ab) then kt:=1;
if (ab=bc) and (ab<>ac) and (bc<>ac) then kt:=1;
if (ab=ac) and (ac=bc) then kt:=2;
if sqr(ab)=sqr(ac)+sqr(bc) then kt:=3;
if sqr(ac)=sqr(ab)+sqr(bc) then kt:=3;
if sqr(bc)=sqr(ab)+sqr(ac) then kt:=3;
if kt=0 then writeln('Day la tam giac thuong');
if kt=1 then writeln('Day la tam giac can');
if kt=2 then writeln('Day la tam giac deu');
if kt=3 then writeln('Day la tam giac vuong');
end
else writeln('Day khong phai la toa do 3 dinh cua mot tam giac');
readln;
end.