1
I’m trying to solve a problem of Uri online Judge for bhaskara formula, but my Output always comes out "Nan" and I don’t know where I went wrong!
Input: 10.0 20.1 5.1
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var valores = Number(lines[0].split(" "));
var a = Number(valores[0]);
var b = Number(valores[1]);
var c = Number(valores[2]);
var b2 = b*b;
var delta = b2-4*(a*c);
if(delta < 0){
console.log('Impossivel calcular');
}
var bneg = b*(-1);
var raizdelta = Math.sqrt(delta);
var divisor = a*a;
var r1 = (bneg+raizdelta)/divisor;
var r2 = (bneg-raizdelta)/divisor;
console.log('R1 = ' + r1);
console.log('R2 = ' + r2);
var valores = Number(lines[0].split(" "))
, ifvalores
is a number, which would bevalores[0]
,valores[1]
andvalores[2]
?– Woss
"var values" is not a number but an array of Number
– Rogerio Pavan da Silva