-
Notifications
You must be signed in to change notification settings - Fork 0
Hw seminar4 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Hw seminar4 #2
Changes from all commits
c2a65b2
446f81e
d89d5fb
9cd7538
b5054fd
7a8ca8d
19ec5db
cf0cf73
8ae44ee
ad69d5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Задача 22: | ||
| # Даны два неупорядоченных набора целых чисел (может быть, с | ||
| # повторениями). Выдать без повторений в порядке возрастания все те числа, которые | ||
| # встречаются в обоих наборах. | ||
| # Пользователь вводит 2 числа. n - кол-во элементов первого множества. m - кол-во | ||
| # элементов второго множества. Затем пользователь вводит сами элементы множеств. | ||
|
|
||
| # 11 6 | ||
| # 2 4 6 8 10 12 10 8 6 4 2 | ||
| # 3 6 9 12 15 18 | ||
|
|
||
| # 6 12 | ||
|
|
||
| def newset(num): | ||
| new_set = set() | ||
| for i in range(num): | ||
| new_set.add(int(input("Введите число для множества: "))) | ||
| return new_set | ||
|
|
||
|
|
||
| n = int(input("Введите кол-во элементов первого множества: ")) | ||
| n_set = newset(n) | ||
|
|
||
| m = int(input("Введите кол-во элементов второго множества: ")) | ||
| m_set = newset(m) | ||
|
|
||
| print(*n_set) | ||
| print(*m_set) | ||
|
|
||
| s_set = sorted(n_set.intersection(m_set)) | ||
| print(*s_set) | ||
|
|
||
| # Задача 24: В фермерском хозяйстве в Карелии выращивают чернику. | ||
| # Она растет на круглой грядке, причем кусты высажены только по окружности. | ||
| # Таким образом, у каждого куста есть ровно два соседних. | ||
| # Всего на грядке растет N кустов с i ягод. | ||
| # Эти кусты обладают разной урожайностью, поэтому ко времени сбора на них | ||
| # выросло различное число ягод – на i-ом кусте выросло a | ||
| # В этом фермерском хозяйстве внедрена система автоматического сбора черники. | ||
| # Эта система состоит из управляющего модуля и нескольких собирающих модулей. | ||
| # Собирающий модуль за один заход, находясь непосредственно перед некоторым | ||
| # кустом, собирает ягоды с этого куста и с двух соседних с ним. | ||
| # Напишите программу для нахождения максимального числа ягод, которое может | ||
| # собрать за один заход собирающий модуль, находясь перед некоторым кустом | ||
| # заданной во входном файле грядки. | ||
|
|
||
| # 4 -> 1 2 3 4 | ||
| # 9 | ||
|
|
||
| from random import randint | ||
| # n = 10 # макс. кол-во ягод на кусте | ||
| list_1 = list(randint(1, 10) for i in range(int(input('Введите кол-во кустов: ')))) | ||
| print(list_1) | ||
| a = int(input('Введите № куста: ')) | ||
| res = 0 | ||
| if a == 1: | ||
| res = list_1[0] + list_1[1] + list_1[-1] | ||
| elif a == len(list_1): | ||
| res = list_1[-2] + list_1[-1] + list_1[0] | ||
| else: | ||
| res = list_1[a - 1] + list_1[a - 2] + list_1[a] | ||
| print(res, 'ягод') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
выполнено