Skip to content

Algorithmf&data structures 3 - #8

Open
SRytv wants to merge 11 commits into
masterfrom
Algorithmf&Data_Structures_3
Open

Algorithmf&data structures 3#8
SRytv wants to merge 11 commits into
masterfrom
Algorithmf&Data_Structures_3

Conversation

@SRytv

@SRytv SRytv commented Oct 3, 2018

Copy link
Copy Markdown
Owner

No description provided.

@Dzhoker1 Dzhoker1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставил комментарии по коду

@@ -0,0 +1,20 @@
#1. В диапазоне натуральных чисел от 2 до 99 определить,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Решение отличное. Сомневались вы зря.
Разве что хорошо будет добавлять пустые строки между отдельными логическими блоками кода. Читать будет легче.

import random

list_1 = []
List_1_LENGTH = 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень странное имя. Это класс или константа? )))


list_1 = []
List_1_LENGTH = 20
for i in range(0, List_1_LENGTH + 1):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ноль в качестве start не указывается в range

if random_list[i] > curr_max['value']:
curr_max['value'] = random_list[i]
curr_max['index'] = i
continue # текущий элнмент уже заведоио не может оказаться минимальным

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если сработала ветка if, то ветка else не сработает. Программа вернётся к циклу и без continue

print ('\n', numbers_list)

for i in range(0, DIFF_NUMBS):
print("В данном массиые число: {: >3d} встречается {: >d} раз".format(i, count_list[i]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Про все числа ответы написали, а на вопрос задачи так и не ответили.

while answer.lower() != 's':
random_list.append(int(answer))
answer = input("Введите следующее число или 'S': ")
curr_max = {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Из улучшений могу предложить такую строку вместо ваших трёх
curr_max = {'index': 0, 'value': random_list[0]}


# выше блок из задачи task_3.py
#=======================================================================================================
sum_elem = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично суммирует

curr_min_1['index'] = i

curr_min_2 = {}
curr_min_2['index'] = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если минимальный элемент оказывается в нулевой ячейке, то второй программа найти не может

for i in range(0, columns_numb):
matrix[j][columns_numb] += matrix[j][i]

print("\nВывод матрицы 5х4, последний 6й элемент каждой строки")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По условию мы не должны добавлять 6-й столбец

@@ -0,0 +1,38 @@
#9. Найти максимальный элемент среди минимальных элементов столбцов матрицы.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличный алгоритм.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants