a = input() b = input() array_a = [0] array_b = [0] if len(a) < len(b): for i in range(len(b) - len(a)): array_a.append(0) elif len(b) < len(a): for i in range(len(a) - len(b)): array_b.append(0) a.split() b.split() for i in a: array_a.append(int(i)) for i in b: array_b.append(int(i)) for i in range(0, len(array_a)): array_a[i] += array_b[i] array_sum = [] array_sum = array_a currentElement = int(len(array_sum) - 1) while currentElement != 0: if array_sum[currentElement] > 9: array_sum[currentElement] -= 10 array_sum[currentElement-1] += 1 currentElement -= 1 else: currentElement -= 1 continue if array_sum[0] == 0: array_sum.remove(0) sum = str() for i in range(0, len(array_sum)): sum = sum + str(array_sum[i]) print(sum)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | a = input() b = input() array_a = [0] array_b = [0] if len(a) < len(b): for i in range(len(b) - len(a)): array_a.append(0) elif len(b) < len(a): for i in range(len(a) - len(b)): array_b.append(0) a.split() b.split() for i in a: array_a.append(int(i)) for i in b: array_b.append(int(i)) for i in range(0, len(array_a)): array_a[i] += array_b[i] array_sum = [] array_sum = array_a currentElement = int(len(array_sum) - 1) while currentElement != 0: if array_sum[currentElement] > 9: array_sum[currentElement] -= 10 array_sum[currentElement-1] += 1 currentElement -= 1 else: currentElement -= 1 continue if array_sum[0] == 0: array_sum.remove(0) sum = str() for i in range(0, len(array_sum)): sum = sum + str(array_sum[i]) print(sum) |