var zc=2*3.1415926*r
var mj=3.1415926*r*r
console.log('圆的周长为:'+zc)
console.log('圆的面积为:'+mj)
}
circle(2)
输入半径r即可输出对应周长和面积
<script type=text/javascript>function showMJ(){
var a=parseFloat(document.getElementById("a").value)
var b=parseFloat(document.getElementById("b").value)
var c=parseFloat(document.getElementById("c").value)
var zc=a+b+c
document.getElementById("zc").value=zc
var p=zc/2
var S=Math.sqrt(parseFloat(p*(p-a)*(p-b)*(p-c)))
document.getElementById("mj").value=S.toFixed(2)
}
</script>
<html>
<body>
<input type=text id="a">
<input type=text id="b">
<input type=text id="c">
<br>
<input type=button value="计算周长和面积" onclick=showMJ()>
周长:<input type=text id="zc">
面积:<input type=text id="mj">
</body>
</html>