package com.thinker.test.test2;

public class Test_2_5_1{
	
	static class ListNode{
		public ListNode(){}
		public ListNode(int data){
			this.data = data;
		}
		ListNode next;
		int data;
	}

	public static  ListNode go(ListNode a,ListNode b,int sign){
		if(a == null && b == null && sign == 0){
			return null;
		}
		ListNode result = new ListNode();
		int sum = 0;
		if(a != null){
			sum += a.data;
		}
		if(b != null){
			sum += b.data;
		}
		sign += sum%10;
		result.data = sign;
		sign = sum/10;
		result.next = go(a==null?null:a.next,b==null?null:b.next,sign>=1?1:0);
		return  result;
		
	}

	public static void main(String[] args){
		ListNode a = new ListNode(7);
		a.next = new ListNode(1);
		a.next.next = new ListNode(6);
		ListNode b = new ListNode(5);
		b.next = new ListNode(9);
		b.next.next = new ListNode(2);
		ListNode result = go(a,b,0);
		System.out.println(result);
	}
}
