This commit is contained in:
Yesen 2023-10-05 14:31:50 +03:00
parent a53633d93a
commit d71ebdb1b3

View File

@ -1,36 +1,53 @@
# вариант решения 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)
# 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)
# 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)
# вариант решения 3
a = [int(item) for item in input().split()]
a2 = []
for i in range(len(a)):
if len(a) == 1:
print(a[0])
break
else:
if i == 0:
a2.append(a[-1] + a[i + 1])
elif i > 0 and i != len(a) - 1:
a2.append(a[i - 1] + a[i + 1])
else:
a2.append(a[i - 1] + a[0])
if a2 != 0:
for i in a2:
print(i, end=' ')