36 lines
982 B
Python
36 lines
982 B
Python
# вариант решения 1
|
|
a = input().split()
|
|
len_a = len(a) - 1
|
|
for index, number in enumerate(a):
|
|
if len_a == 0:
|
|
print (number)
|
|
else:
|
|
if index == 0:
|
|
S = int(a[-1]) + int(a[1])
|
|
b = str(S)
|
|
elif index != 0 and index != int(len_a) :
|
|
n_index_0 = int(int(a.index(number)) + 1)
|
|
n_index_2 = int(int(a.index(number)) - 1)
|
|
n_0 = a[n_index_0]
|
|
N_2 = a[n_index_2]
|
|
S1 = int(n_0) + int(N_2)
|
|
b += " " + str(S1)
|
|
elif index == int(len_a):
|
|
S2 = int(a[0]) + int(a[-2])
|
|
b += " " + str(S2)
|
|
print (b)
|
|
|
|
|
|
# вариант решения 2 -короче
|
|
initial_list = input().split()
|
|
sum_list = []
|
|
left_index = -1
|
|
right_index = -len(initial_list) + 1
|
|
middle_index = 0
|
|
while middle_index < len(initial_list):
|
|
sum_list.append(initial_list[left_index] + initial_list[right_index])
|
|
left_index += 1
|
|
right_index += 1
|
|
middle_index += 1
|
|
print(sum_list)
|
|
|