如何在半径为4的圆上显示半径和面积与圆周的比率,并在比率小于10时继续显示?
答案 0 :(得分:0)
周长= 2 * pi * r
Area = pi * r ^ 2
比率面积:周长= r / 2
所以你必须从4到19或20迭代。
答案 1 :(得分:0)
// ratio = (pi*r^2)/(2*pi*r) = r/2
// let x and y define the center coordinate
var circles = [{x:0,y:0,r:5},{x:10,y:10,r:17},{x:20,y:20,r:31}];
circles = circles.filter(function(k){ return k.r/2 < 10});
答案 2 :(得分:0)
假设你要显示面积与环绕的比率,直到比率小于10,从半径4开始。
试试这段代码
var ratio = 0;
var radius = 4;
while(ratio < 10 )
{
var area = Math.PI * radius * radius;
var circumfence = 2 * Math.PI * radius;
var ratio = area/circumfence;
document.body.innerHTML += "Ratio of area to circumfence for radius " + radius + " is " + ratio );
radius++;
}