a)Hình vuông
Program bt;
Var a,S,Cv:integer;
Begin
Writeln('Nhap a:=');
Readln(a);
S:=a*a;
Writeln('Dien tich hinh vuong la:=',S);
Cv:=a*4;
Writeln('Chu vi hinh vuong la:=',Cv);
Readln;
End.
mình dồn 5 cái này vào cùng 1 bài luôn
program thinh;
uses crt;
var a,dt,dai,rong,dt_hcn,r,c1,c2,c3,hthang,c,d,b,cv,cv_hcn,b1,b2,cv_ht:integer;
hinh:string;
s_tron,p,s,s_ht,cv_tron,cv_tg:real;
begin
clrscr;
write('nhap hinh ban muon tinh chu vi va dien tich:'); readln(hinh);
case hinh of
'hinh vuong':
begin
repeat
write('nhap canh cua hinh vuong:'); readln(a);
if a<=0 then writeln('ban da nhap sai, yeu cau ban nhap lai');
until a>0;
cv:=a*4;
dt:=a*a;
writeln('chu vi cua hinh vuong co canh ',a,'cm la: ',cv);
writeln('dien tich hinh vuong co canh la: ',a,'cm la: ',dt);
end;
'hinh chu nhat':
begin
repeat
write('nhap chieu dai:'); readln(dai);
write('nhap chieu rong:'); readln(rong);
if (dai<=rong) or (dai<=0) or (rong<=0) then
writeln('ban da nhap sai, yeu cau ban nhap lai');
until (dai>rong) and (dai>0) and (rong>0);
cv_hcn:=(dai+rong)*2;
dt_hcn:=dai*rong;
writeln('chu vi hinh chu nhat co chieu dai la ',dai,'cm va chieu rong la ' ,rong,'cm la: ',cv_hcn);
writeln('dien tich hinh chu nhat co chieu dai la ',dai,'cm va chieu rong la ' ,rong,'cm la: ',dt_hcn);
end;
'hinh tron':
begin
repeat
write('nhap ban kinh:'); readln(r);
if r<=0 then writeln('ban da nhap sai, yeu cau ban nhap lai');
until r>0;
cv_tron:=2*r*pi;
s_tron:=sqr(r)*pi;
writeln('chu vi hinh tron co ban kinh la ',r,'cm la: ',cv_tron:4:2);
writeln('dien tich hinh tron co ban kinh la ',r,'cm la: ',s_tron:4:2);
end;
'hinh tam giac':
begin
repeat
write('nhap canh thu 1:'); readln(c1);
write('nhap canh thu 2:'); readln(c2);
write('nhap canh thu 3:'); readln(c3);
if (c1+c2<=c3) or (c1+c3<=c2) or (c2+c3<=c1) then
writeln('ban da nhap sai, yeu cau ban nhap lai');
until (c1+c2>c3) and (c1+c3>c2) and (c2+c3>c1);
p:=(c1+c2+c3)/2;
cv_tg:=p*2;
s:=sqrt(p*(p-c1)*(p-c2)*(p-c3));
writeln('chu vi hinh tam giac co 3 canh lan luot la: ',c1,'cm;',c2,'cm;',c3,'cm la: ',cv_tg:4:2);
writeln('dien tich hinh tam giac co 3 canh lan luot la: ',c1,'cm;',c2,'cm;',c3,'cm la: ',s:4:2);
end;
'hinh thang':
begin
write('nhap chieu cao hinh thang:'); readln(hthang);
write('nhap canh day thu 1:'); readln(c);
write('nhap canh day thu 2:'); readln(d);
write('nhap canh ben thu 1: '); readln(b1);
write('nhap canh ben thu 2: '); readln(b2);
s_ht:=1/2*hthang*(c+d);
cv_ht:=c+d+b1+b2;
writeln('dien tich hinh thang co do dai hai canh day la: ',c,'cm va ',d,'cm la: ',s_ht:4:2);
writeln('chu vi hinh thang co do dai hai canh ben la: ',b1,'cm va ',b2,'cm; do dai hai canh day la: ',c,'cm va ',d,'cm la: ',cv_ht);
end;
end;
readln;
end.
tên các phần mik đã ghi ở trên chương trinh rồi nhé
bn tự khai báo hết nhé!!
a)begin
clrscr;
write('nhap canh a=');readln(a);
s:=a*a;
cv:=a*4;
writeln('dien tich la:',s:10:2);
writeln('chu vi la:',cv:10:2);
readln
end.
b)
clrscr;
write('nhap canh a:');readln(a);
write('nhap canh b:');readln(b);
s:=a*b;
cv:=(a+b)*2;
writeln('chu vi la:',cv:10:2);
writeln('dien tich la:',s:10:2);
readln
end.
c)program htg;
uses crt;
var a,b,c,p,s,cv:real;
begin
clrscr;
write ('nhap canh a=');readln(a);
write('nhap canh b=');readln(b);
write('nhap canh c=');readln(c);
cv:=a+b+c;
p:=cv/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('chu vi la:',cv:10:2);
writeln('dien tich la:',s:10:2);
readln
end.
d)begin
clrscr;
write('nhap ban kinh=');readln(r);
s:=pi*r*r;
cv:=2*pi*r;
Writeln(‘Dien tich hinh tron la:’,dt:6:2); Writeln(‘Chu vi hinh tron la:’,cv:6:2);
Readln;
End.
mk chỉ bt thế thôi!!