Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static char[] add(char[] arrayOne, char[] arrayTwo, int lengthOne, int lengthTwo)
- {
- char[] sum = new char[20];
- int firstNum, secondNum, smallSum;
- for(int i = 0; i < 20; i++)
- {
- firstNum = (Integer.valueOf(arrayOne[i]) - 48); //48 is the offset of the ASCII value
- secondNum = (Integer.valueOf(arrayTwo[i]) - 48);
- smallSum = firstNum + secondNum;
- if(smallSum >= 10)
- {
- smallSum = smallSum%10;
- }
- sum[i] = Character.forDigit(smallSum, 10);
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement