Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Input Kotlin输入为BigInteger_Input_Kotlin_Biginteger - Fatal编程技术网

Input Kotlin输入为BigInteger

Input Kotlin输入为BigInteger,input,kotlin,biginteger,Input,Kotlin,Biginteger,我想读取两个50位数字并打印它们的总和,但我无法在Kotlin中以BigInteger的形式获取输入 如何将Kotlin输入读取为BigInteger 有没有其他办法解决这个问题 您可以使用与Java中相同的方法执行此操作: val scanner = Scanner(System.`in`) val first = scanner.nextBigInteger() val second = scanner.nextBigInteger() print(first + second) 或您可

我想读取两个50位数字并打印它们的总和,但我无法在Kotlin中以BigInteger的形式获取输入

  • 如何将Kotlin输入读取为BigInteger
  • 有没有其他办法解决这个问题

  • 您可以使用与Java中相同的方法执行此操作:

    val scanner = Scanner(System.`in`)
    val first = scanner.nextBigInteger()
    val second = scanner.nextBigInteger()
    
    print(first + second)
    
    您可以从
    kotlin.io
    使用
    readLine()

    val first = BigInteger(readLine())
    val second = BigInteger(readLine())
    
    print(first + second)
    

    与Java中的相同。你在哪里卡住了?这里
    var-sum:biginger=readLine().toBigInteger()
    。ToBiginGeter()是一个未解析的引用。它未解析,因为Kotlin中没有BigInteger类型。您必须使用Java的BigInteger。@AksharPatel我看到了这一点,但我的问题是“如何获得BigInteger输入?”非常感谢,它成功了。有没有办法用
    readLine()
    代替扫描仪?