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.
uses crt;
var a,b:integer;
{-----------------chuong-trinh-con-tinh-chu-vi----------------------------------}
function cv(x,y:integer):integer;
begin
cv:=x+y;
end;
{-------------------chuong-trinh-con-tinh-dien-tich-----------------------------}
function dt(x,y:integer):integer;
begin
dt:=x*y;
end;
{-------------------------chuong-trinh-chinh-------------------------}
begin
clrscr;
write('Nhap chieu dai:'); readln(a);
write('Nhap chieu rong:'); readln(b);
writeln('Chu vi la: ',cv(a,b));
writeln('Dien tich la: ',dt(a,b));
readln;
end.
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.
uses crt;
const fi='dulieu.dat';
var f1:text;
a,b,p,s:array[1..100]of real;
i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(a[n],b[n]);
end;
for i:=1 to n do
begin
p[i]:=(a[i]+b[i])/2;
s[i]:=a[i]*b[i];
end;
for i:=1 to n do
writeln(p[i]:4:2,' ',s[i]:4:2);
close(f1);
readln;
end.
Bài 5:
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<(a+b)*2;
return 0;
}
uses crt;
const fi='baitap.txt';
var f1:text;
a,b:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,a,b);
writeln('Chu vi la: ',(a+b)*2);
writeln('Dien tich la: ',a*b);
close(f1);
readln;
end.
uses crt;
const fi='baitap.txt';
var f1:text;
a,b:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,a,b);
writeln('Chu vi hinh chu nhat la: ',(a+b)*2);
close(f1);
readln;
end.
Bài 1:
uses crt;
var a,b:real;
{----------------------------chuong-trinh-con-tinh-chu-vi-------------------------}
function chuvi(x,y:real):real;
begin
chuvi:=(x+y)*2;
end;
{----------------------------chuong-trinh-con-tinh-dien-tich----------------------}
function dientich(m,n:real):real;
begin
dientich:=m*n;
end;
{-----------------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
repeat
write('Nhap chieu dai:'); readln(a);
write('Nhap chieu rong:'); readln(b);
until (a>0) and (b>0) and (a>=b);
writeln('Chu vi hinh chu nhat la: ',chuvi(a,b):4:2);
writeln('Dien tich hinh chu nhat la: ',dientich(a,b):4:2);
readln;
end.
Bài 2:
uses crt;
var a,b,c:real;
{----------------------------chuong-trinh-con-tinh-chu-vi-------------------------}
function chuvi(x,y,z:real):real;
begin
chuvi:=x+y+z;
end;
{----------------------------chuong-trinh-con-tinh-dien-tich----------------------}
function dientich(m,n,p:real):real;
var ncv:real;
begin
ncv:=(m+n+p)/2;
dientich:=sqrt(ncv*(ncv-m)*(ncv-n)*(ncv-p));
end;
{-----------------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
repeat
write('Nhap canh thu 1:'); readln(a);
write('Nhap canh thu 2:'); readln(b);
write('Nhap canh thu 3:'); readln(c);
until (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a);
writeln('Chu vi hinh tam giac la: ',chuvi(a,b,c):4:2);
writeln('Dien tich hinh tam giac la: ',dientich(a,b,c):4:2);
readln;
end.
Bài 3:
uses crt;
var r:real;
{----------------------------chuong-trinh-con-tinh-chu-vi-------------------------}
function chuvi(x:real):real;
begin
chuvi:=2*x*pi;
end;
{----------------------------chuong-trinh-con-tinh-dien-tich----------------------}
function dientich(m:real):real;
begin
dientich:=sqr(m)*pi;
end;
{-----------------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
repeat
write('Nhap ban kinh:'); readln(r);
until r>0;
writeln('Chu vi hinh tron la: ',chuvi(r):4:2);
writeln('Dien tich hinh tron la: ',dientich(r):4:2);
readln;
end.
Bài 4:
uses crt;
var a,b:real;
{--------------------chuong-trinh-con-tinh-tong------------------------}
function tong(x,y:real):real;
begin
tong:=x+y;
end;
{--------------------chuong-trinh-con-tinh-hieu------------------------}
function hieu(m,n:real):real;
begin
hieu:=m-n;
end;
{--------------------chuong-trinh-con-tinh-tich------------------------}
function tich(c,d:real):real;
begin
tich:=c*d;
end;
{--------------------chuong-trinh-con-tinh-thuong-----------------------}
function thuong(p,q:real):real;
begin
thuong:=p/q;
end;
{--------------------chuong-trinh-chinh--------------------------------}
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
writeln('Tong cua hai so la: ',tong(a,b):4:2);
writeln('Hieu cua hai so la: ',hieu(a,b):4:2);
writeln('Tich cua hai so la: ',tich(a,b):4:2);
if b<>0 then writeln('Thuong cua hai so la: ',thuong(a,b):4:2)
else writeln('Khong tinh duoc thuong cua hai so vi so chia bang 0');
readln;
end.