演算法設計 實驗一 求解兩圓相交的面積

2021-10-09 14:18:11 字數 1136 閱讀 7130

實驗一:求兩圓相交的面積,題目來自poj,題號2546

in the single line of input file there are space-separated real numbers x1 y1 r1 x2 y2 r2. they represent center coordinates and radii of two circles.

step1:輸入兩個圓的引數 x1、 y1、 r1、 x2、 y2、 r2。

step2:計算 a,b的距離d。

若d>=(ra+rb),則 s=0;否則,進入 step3

step3:較大的圓為圓a的圓心(xa,yb),半徑 ra;

較小的圓b的圓心( xc,yd 半徑 rb。

若d<=(ra-rb) 則輸出 s=pi* rb * rb

否則,若ra-rbm所對扇面積sx=mrara;

m所對三角形面積ss=sinmcosm ra*ra;

s1=sx-ss;

同理,計算圓a內重疊部分s2。

s=s1+s2。

step6: 輸出s返回 。

#include

#include

#include

using

namespace std;

#define pi 2*asin(1.0)

void

setsize

(double

& a,

double

& b,

double

& c,

double

& d,

double

& r1,

double

& r2)

else

return;}

double

fun(

double x,

double r)

intmain()

else

else

} cout <<

setiosflags

(ios::fixed)

<<

setprecision(3

)<< s << endl;

return0;

}

兩圓相交求相交面積

1.海 式 2.余弦公式cosa public double areaofintersectionofcircles int firstx,int firsty,int firstr,int secondx,int secondy,int secondr alpha math.acos d d fi...

求兩圓是否相交

呃.貌似 是很簡單 今天課間休息 照了張相片用q發給爸爸了 另作上傳頭像用 這個實訓第五天了 從第一天helloworld 講到遞迴 呵呵 慢慢來 剛好複習 我們也要求每天寫日誌 我突然想起csdn 也來寫寫 只是隨便寫寫 別砸我 沒人看就算了 有人看就算了 先每天都寫了好多個 隨便來乙個 類cir...

模版 兩圓相交部分面積

題目 poj 2546 circular area 題意 計算兩圓公共部分面積 260k 0ms g 提交wa,c 提交ac o o include include include include include include using namespace std const double ep...