1
如何将包含十进制数的字符串数组转换为大整数?将十进制数组转换为biginteger
如:
String s={"1","2","30","1234567846678943"};
我当前的代码:
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String s[]= new String[n];
for(int i=0; i < n; i++){
s[i] = in.next();
}
BigInteger[] b = new BigInteger[n];
for (int i = 0; i < n; i++) {
b[i] = new BigInteger(String s(i));
}
你并不需要填充一个“字符串”数组并将其稍后转换为一个BigInteger数组。你可以用一个for循环来完成。 'BigInteger [] b = new BigInteger [n]; for(int i = 0; i