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;
int main()
{
int a,b;
freopen("hcn.inp","r",stdin);
freopen("hcn.out","w",stdout);
cin>>a>>b;
cout<<(a+b)*2<<endl;
cout<<a*b;
return 0;
}
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.
#include <bits/stdc++.h>
using namespace std;
double a,b,cv,dt;
int main()
{
cin>>a>>b;
cv=(a+b)*2;
dt=a*b;
cout<<fixed<<setprecision(2)<<cv<<endl;
cout<<fixed<<setprecision(2)<<dt;
return 0;
}
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='x.inp';
var f1:text;
a,b:array[1..100]of integer;
i,n:integer;
begin
assign(f1,fi); reset(f1);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n],b[n]);
end;
for i:=1 to n do
begin
writeln('Chu vi dong ',i,' la: ',(a[i]+b[i])*2);
writeln('Dien tich dong ',i,' la: ',a[i]*b[i]);
end;
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;
var a,b,cv,s:longint;
begin
clrscr;
write('a=');readln(a);
write('b=');readln(b);
cv:=(a+b)*2;
s:=a*b;
writeln('chu vi cua hinh chu nhat do la:',cv);
write('dien tich cua hinh chu nhat do la:',s);
readln;
end.