package com.company;
import java.util.Objects;
public class Main {
public static void main(String[] args) {
// write your code here
String num1 = "30000001";
String num2 = "1000003";
if (!isDigitalNum(num1) || !isDigitalNum(num2)) {
System.out.println("数值不合法");
return;
}
Node node1 = new Node.Builder().setNumber(num1).build();
Node node2 = new Node.Builder().setNumber(num2).build();
String result = node1.next.add(node2.next, 0);
for (int i = 0; i < result.length(); ++i) {
if (result.charAt(i) != '0') {
System.out.println(result.substring(i));
break;
}
}
}
private static boolean isDigitalNum(String num) {
if (Objects.isNull(num) || "".equals(num))
return false;
for (int i = 0; i < num.length(); i++) {
if (num.charAt(i) < '0' && num.c
用链表的方式实现大数相加-Java实现
最新推荐文章于 2022-09-24 13:45:35 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)