题解 | #乘法#

乘法

http://www.nowcoder.com/practice/6429776e4630435cbc3eeb36bdf41f83

function multiply(a, b) {

if(a > 1&& b < 1){
    b_dottod_length = (''+b).slice((''+b).indexOf('.')+1);
    dottod = -(a.toString.length)+1+b_dottod_length.length
}else if(b > 1&&a < 1){
    a_dottod_length = (''+a).slice((''+a).indexOf('.')+1);
    dottod = -(b.toString.length)+1+a_dottod_length.length;
}else if(b < 1&& a < 1){
    a_dottod_length = (''+a).slice((''+a).indexOf('.')+1);
    b_dottod_length = (''+b).slice((''+b).indexOf('.')+1);
    dottod = a_dottod_length.length + b_dottod_length.length
    console.log(dottod)
}else{
    return a*b;

}
return (a*b)>=1?(a*b):(a*b).toFixed(dottod)

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务