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