【C#の存亡】C#って死滅しちゃうの? Part4
■ このスレッドは過去ログ倉庫に格納されています
0801デフォルトの名無しさん
NGNGnamespace CSharp{
class CSharp{
static double calc(double x1, double y1, double x2, double y2, int Depth)
{
if( x1 * x1 + y1 * y1 >= 1 ) return 0.0;
if( x2 * x2 + y2 * y2 <= 1 ) return (x2-x1)*(y2-y1);
if( Depth <= 0 ) return (x2-x1)*(y2-y1)/2;
double x = (x1 + x2) / 2;
double y = (y1 + y2) / 2;
return
calc(x1, y1, x , y , Depth-1) +
calc(x1, y , x , y2, Depth-1) +
calc(x , y1, x2, y , Depth-1) +
calc(x , y , x2, y2, Depth-1) ;
}
static double getpi(){
return calc(0.0, 0.0, 1.0, 1.0, 27) * 4;
}
static void Main(){
Console.WriteLine(getpi());
}
}
}
■ このスレッドは過去ログ倉庫に格納されています