加法:
减法:
乘法:
AN = 1 ; BN = 1
AN_array = [] ; BN_array = []
while True:
AN = input('')
if AN == '':
break
AN_array.append([i for i in AN.split(' ') if i != ''])
operator = input('')
while True:
BN = input('')
if BN == '':
break
BN_array.append([i for i in BN.split(' ') if i != ''])
new_array = []
for i1 in range(len(AN_array)):
temp = []
for i2 in range(len(AN_array[i1])):
if operator == "+":
temp.append('{:^5}'.format(int(AN_array[i1][i2])+int(BN_array[i1][i2])))
if operator == "-":
temp.append('{:^5}'.format(int(AN_array[i1][i2]) - int(BN_array[i1][i2])))
if operator == "*":
temp.append('{:^5}'.format(int(AN_array[i1][i2]) * int(BN_array[i1][i2])))
new_array.append(''.join(temp))
for i in new_array:
print(i)
|