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;
}
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.
Câu 1:
uses crt;
var a,b,c,p,s: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
begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich tam giac la: ',s:4:2);
end
else writeln('Day khong la ba canh trong mot tam giac');
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac phan tu trong day la: ',t);
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
nếu câu b bài 2 được tách riêng thành 1 câu riêng biệt...thì thay thế bắt đầu từ đâu ạ
#include <bits/stdc++.h>
using namespace std;
double xa,ya,xb,yb,xc,yc,ab,ac,bc,am;
int main()
{
cin>>xa>>ya>>xb>>yb>>xc>>yc;
ab=sqrt(pow(xa-xb,2)+pow(ya-yb,2));
ac=sqrt(pow(xa-xc,2)+pow(ya-yc,2));
bc=sqrt(pow(xb-xc,2)+pow(yb-yc,2));
cout<<"AB="<<fixed<<setprecision(2)<<ab<<endl;
cout<<"AC="<<fixed<<setprecision(2)<<ac<<endl;
cout<<"BC="<<fixed<<setprecision(2)<<bc<<endl;
am=((2*(ac*ac+bc*bc)-ab*ab)/4);
cout<<"AM="<<fixed<<setprecision(2)<<sqrt(am)<<endl;
return 0;
}
uses crt;
var a,b,c,p,s: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) and (a+b>c) and (a+c>b) and (b+c>a);
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln(s:4:2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
if(a==b)
{if (b!=c) {cout << "Ba so da nhap la do dai ba canh cua mot tam giac can";}
if(b==c) {cout << "Ba so da nhap la do dai ba canh cua mot tam giac deu";}}
if(b==c)
{if(a!=b) {cout << "Ba so da nhap la do dai ba canh cua mot tam giac can";}}
if(a==c)
{if(a!=b) {cout << "Ba so da nhap la do dai ba canh cua mot tam giac can";}}
if(a!=b)
{if(b!=c) {cout << "Ba so da nhap khong la do dai ba canh cua mot tam giac can";}}
return 0;
}
Chúc bn học tốt! (Bonus thêm trường hợp không là độ dài tam giác cân và là độ dài của tam giác đều nha!)
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.
uses crt;
var xa,ya,xb,yb,xc,yc,p,s,ab,ac,bc: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));
p:=(ab+bc+ac)/2;
s:=sqrt(p*(p-ab)*(p-bc)*(p-ac));
writeln('Dien tich tam giac la: ',s:4:2);
readln;
end.