如何解决这个JavaScript数学问题?

时间:2019-05-26 18:28:39

标签: javascript

在Uri Online Judge网站上,我需要有关此逻辑problem的帮助。

提交的代码以“ var a”开头,最后一个console.log 结尾,我使用var行来处理输入示例

var lines = ["3.0", "4.0", "5.2"];  
/**
 * Code your solution here
 */
var a = parseFloat(lines[0]); 
var b = parseFloat(lines[1]); 
var c = parseFloat(lines[2]); 
var areatr = (a * c) / 2; 
var areac = 3.14159 * (c * c); 
var areat = ((a + b) * c) / 2; 
var areaq = b * b; 
var arear = a * b; 

console.log("TRIANGULO: " + areatr.toFixed(3)); 
console.log("CIRCULO: " + areac.toFixed(3)); 
console.log("TRAPEZIO: " + areat.toFixed(3)); 
console.log("QUADRADO: " + areaq.toFixed(3)); 
console.log("RETANGULO: " + arear.toFixed(3));

当我提交代码时,控制台显示:错误的答案(30%) code submitted

1 个答案:

答案 0 :(得分:2)

更改输入的处理方式
从: var lines = input.split('\n');
至: var lines = input.split(' ');