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.
const fi='hinhtron.inp';
fo='hinhtron.out';
var f1,f2:text;
a:array[1..100]of real;
i,n:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
read(f1,a[n]);
end;
for i:=1 to n do
writeln(f2,'Hinh tron thu ',i,': Chu vi la ',(2*a[n]*pi):4:2,' va Dien tich la: ',a[n]*a[n]*pi:4:2);
close(f1);
close(f2);
end.
Tham khảo!
Program tich_chu_vi_dien_tich_hinh_tron;
uses crt; //Khai bao thu vien
var r,dien_tich,chu_vi:real; //Khai bao bien
begin
clrscr;
//Input:
write(‘Nhap ban kinh: ‘);readln(r);
//Output:
chu_vi:=r*2*pi;
dien_tich:=r*r*pi;
writeln(‘Chu vi: ‘,chu_vi:0:5);
writeln(‘Dien tich: ‘,dien_tich:0:5);
readln
end.
#include <iostream>
#include <iomanip>
int main() {
int r;
std::cin >> r;
double pi = 3.14;
double perimeter = 2 * pi * r;
double area = pi * r * r;
std::cout << std::fixed << std::setprecision(2);
std::cout << "p= " << perimeter << std::endl;
std::cout << "s= " << area << std::endl;
return 0;
}
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int r;
const float Pi = 3.14;
cout << "Nhap ban kinh hinh tron: ";
cin >> r;
float chu_vi = 2 * Pi * r;
float dien_tich = Pi * r * r;
cout << fixed << setprecision(2);
cout << "p= " << chu_vi << endl;
cout << "s= " << dien_tich << endl;
return 0;
}
Code c:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define PI 3.14159
int main() {
int r;
float chuvi, dientich;
printf("Nhap ban kinh r:");
scanf("%d", &r);
chuvi = 2*PI*r;
dientich = PI*r*r;
printf("Chu vi hinh tron la: %f\n", chuvi);
printf("Dien tich hinh tron la: %f", dientich);
getch();
BN THAM KHẢO:
Program S_Hinh_Tron;
Uses Crt;
Var r,S:real;
Begin
Clrscr;
Writeln(‘TINH DIEN TICH HINH TRON:’);
Write (‘Nhap ban kinh R=’);readln(r);
dt:=pi*r*r;
Writeln(‘Dien tich hinh tron la:’,dt:6:2);
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.
uses crt;
const fi='so.inp';
var f1:text;
a,b:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
while not eof(f1) do
begin
readln(f1,a,b);
writeln((a+b)/2:4:2);
end;
close(f1);
readln;
end.
Câu 1:
uses crt;
const fi='bai1.inp';
var f1:text;
a,b:real;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,a,b);
writeln(a*b:4:2);
close(f1);
readln;
end.
Câu 2:
const fi='bai2.inp';
fo='bai2.out';
var f1,f2:text;
a,b:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b);
writeln(f2,a*b:4:2);
close(f1);
close(f2);
end.
program TinhDienTichHinhTron;
var
fIn, fOut: Text;
r: Integer;
dien_tich: Real;
begin
Assign(fIn, 'dt_ht.inp');
Reset(fIn);
Readln(fIn, r);
Close(fIn);
Assign(fOut, 'dt_ht.out');
Rewrite(fOut);
dien_tich := Pi * r * r;
Writeln(fOut, FormatFloat('0.00', dien_tich));
Close(fOut);
end.