Đây là Code, Mình chỉ sưu tầm, chưa test vì máy ko có pascal.
Code:
Program tinh_dien_tich_phan_giao_hai_duong_tron;
Var
x1,y1,x2,y2,i,j,r1,r2,k,h,s:real;
Function dist(x,y,u,v:real):real;
{distance between (x,y) and (u,v)}
Begin
dist:=sqrt(sqr(x-u)+sqr(y-v));
End;
Procedure init;
Var f :text;
Begin
assign(f,'circle.inp');
reset(f);
read(f,x1,y1,r1);
read(f,x2,y2,r2);
close(f);
s:=0
End;
Procedure result;
Var f :text;
Begin
assign(f,'circle.out');
rewrite(f);
writeln(f,s:5:2);
writeln(f,pi*(r1*r1+r2*r2)-s:5:2);
close(f);
End;
Procedure solve;
Begin
init;
if dist(x1,y1,x2,y2)
i:=x1-r1;k:=x1+r1;
h:=y1+r1;
while i
begin
j:=y1-r1;
while j
begin
if dist(i,j,x1,y1)
if dist(i,j,x2,y2)
j:=j+0.05;
end;
i:=i+0.05;
end;
result;
end;
begin
solve;
end.
Bookmarks