Viết chương trình Pascal tính diện tích tam giác
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.
Program Hinh_Tamgiac_Program;
Uses crt;
Var a,b,c,s,p : real;
Begin
Clrscr;
Writeln(‘HINH TAM GIAC:’);
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
Begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c)); Writeln(‘Chu vi tam giac:’,2*p:4:2) ; Writeln(‘Dien tich tam giac:’,s:4:2);
End
Else
Writeln(a,’, ‘, b,’, ‘, c, ‘ khong phai la ba canh cua tam giac’) ;
Readln;
End.
uses crt;
var a,b,c:real;
begin
clrscr;
readln(a,b,c);
writeln(a+b+c:4:2);
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;
}
b: #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)<<p;
return 0;
}
cái này thì mình ko chắc lắm!
Program Chu_nhat
uses crt;
Var x, y, S;
Begin Write(“Nhap chieu dai:”);
readln(x);
Write(“Nhap chieu rong:”);
readln(y);
S := x*y;
Writeln(“Dien tich hinh chu nhat la:”,S)
readln;
end.
Var r,s,c:real;
Begin
Write('Ban kinh = ');readln(r);
s:=3.14*r*r;
c:=2*3.14*r;
Writeln('Dien tich la ',s:10:2);
Write('Chu vi la ',c:10:2);
Readln
End.
Program Chu_nhat
uses crt;
Var x, y, S;
Begin Write(“Nhap chieu dai:”);
readln(x);
Write(“Nhap chieu rong:”);
readln(y);
S := x*y;
Writeln(“Dien h hinh chu nhat la:”,S)
readln;
end.
Program Dien_tich_tam_giac;
Var
a,b,c:Integer;
p,s:Real;
Begin
Writeln('DIEN TICH TAM GIAC');
Writeln('------------------');
Write('-Nhap so thu nhat: ');
Readln(a);
Write('-Nhap so thu hai : ');
Readln(b);
Write('-Nhap so thu ba : ');
Readln(c);
If (a+b>c) And (b+c>a) And (c+a>b) Then
Begin
Writeln('+Dung la Tam giac');
p:=0.5*(a+b+c);
s:=Sqrt(p*(p-a)*(p-b)*(p-c));
Writeln('+Dien tich= ',s:10:2);
End
Else
Writeln('+Khong phai la Tam giac');
Writeln;
Writeln(' Bam phim <Enter> de ket thuc');
Readln
End.