传入两个只有数字字符组成的字符串,返回相乘结果 StringBuilder multiplyTwoIntegerNum(StringBuilder num1, StringBuilder num2){ int length1 = num1.length(); int length2 = num2.length(); int[] multiplyArray = new int[lengt
StringBuilder multiplyTwoIntegerNum(StringBuilder num1, StringBuilder num2){ int length1 = num1.length(); int length2 = num2.length(); int[] multiplyArray = new int[length1 + length2]; for (int i = length1 - 1; i > -1; i--) { for (int j = length2 - 1; j > -1; j--) { multiplyArray[i + j] += (num1.charAt(i) - '0') * (num2.charAt(j) - '0'); } } StringBuilder result = new StringBuilder(); for (int i = multiplyArray.length - 2; i > 0; i--) { int d = multiplyArray[i] % 10; int c = multiplyArray[i] / 10; multiplyArray[i - 1] += c; result.insert(0, d); } result.insert(0, multiplyArray[0]); return result; }