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.
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,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;
const fi='bai1.inp';
var f1:text;
a,b,c,cv,dt,p:real;
begin
clrscr;
assign(f1,fi); rewrite(f1);
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
cv:=a+b+c;
p:=cv/2;
dt:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln(f1,'Chu vi la: ',cv:4:2);
writeln(f1,'Dien tich la: ',dt:4:2);
end
else writeln(f1,'Day khong la ba canh trong mot tam giac');
close(f1);
readln;
end.
cho em hỏi cái này viết ra thuật toán thì viết kiểu sao ạ
Tham khảo
program hcn;
uses crt;
var d,r,dt:longint;
cv:real;
begin
write('nhap chieu dai va chieu rong cua hcn:');
readln(d,r);
cv:=(d+r)*2;
dt:=d*r;
writeln(' chu vi hcn do la:',cv);
writeln(' dien tich hcn do la:',dt);
readln
end.
#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<<"Chu vi la:"<<fixed<<setprecision(2)<<p*2<<endl;
cout<<"Dien tich la:"<<fixed<<setprecision(2)<<s;
return 0;
}
Bài 2:
uses crt;
var x,i,n,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then inc(dem);
end;
writeln(dem);
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.