题解 | #高精度整数加法#

高精度整数加法

https://www.nowcoder.com/practice/49e772ab08994a96980f9618892e55b6

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    let str1 = await readline()
    let str2 = await readline()
    // 在ES6中提供了BigInt数据类型,方便我们进行大数据的运算
    let num1 = BigInt(str1)
    let num2 = BigInt(str2)
    // 使用toString()方法是由于使用了BigInt之后,数据自身的结尾会携带一个n
    console.log((num1 + num2).toString()); 
}();

在线编程题解 文章被收录于专栏

web技术

全部评论

相关推荐

06-26 17:24
已编辑
宁波大学 Java
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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