Viết chương trình tính diện tích tam giác có các cạnh bằng 7,9,12
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 a,b,c,s,p;
int main()
{
//freopen("DTTAMGIAC.inp","r",stdin);
//freopen("DTTAMGIAC.out","w",stdout);
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(5)<<p*2<<endl;
cout<<fixed<<setprecision(5)<<s;
return 0;
}
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.
2:
#include <bits/stdc++.h>
using namespace std;
double a,b,c,p,s;
int main()
{
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
uses crt;
var a:int64;
begin
clrscr;
readln(a);
writeln('Chu vi la:',a*4);
writeln('Dien tich la: ',a*a);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double p,a,b,c,cv,s;
int main()
{
cin>>a>>b>>c;
cv=a+b+c;
p=cv/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<cv<<endl;
cout<<fixed<<setprecision(2)<<s;
return 0;
}
Program dung;
uses crt;
var s,a,b: real;
begin
clrscr;
write('Nhap a; b : '); readln(a,b);
s:=(a*b)/2;
writeln('Dien tich tam giac vuong la: ',s:1:2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<fixed<<setprecision(2)<<(a*b)/2;
return 0;
}
Viết chương trình nhập vào cạnh đáy và chiều cao của tam giác. tính và in ra diện tích của tam giác.
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<a*b/2;
return 0;
}
uses crt;
var p,dt:real;
begin
clrscr;
p:=(7+9+12)/2
s:=sqrt(p*(p-7)*(p-9)*(p-12))
writeln('dien tich la: ',s);
readln;
end.
Chú ý dấu ";" khi kết thúc câu lệnh b nhé.