Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- ############################# Введём количество строк и столбцов
- rows=int(input('Num of rows: '))
- cols=int(input('Num of cols: '))
- ############################# Сгенерируем массив заданного размера
- r=random.randint(1,100)
- mas = []
- for i in range(rows):
- mas.append([])
- for j in range(cols):
- mas[i].append(r)
- r = random.randint(1,100)
- ############################# Выведем сгенерированный массив
- for i in range(rows):
- print(mas[i], "\n")
- ############################# Вводим координаты элемента. Номер строки.
- m_row=int(input("Enter the number of a row, which will be used in max search:"))
- while (m_row>rows or m_row==rows or m_row<0):
- m_row=int(input("Bad Condition. Entered number shouldn't be equals/bigger/smaller than source number of rows: "))
- ############################# Номер столбца
- m_col=int(input("Enter the number of a col, which will be used in max search:"))
- while (m_col>cols or m_col==cols or m_col<0):
- m_col=int(input("Bad Condition. Entered number shouldn't be equals/bigger/smaller than source number of cols: "))
- ############################# Debug info
- print(m_row,m_col, " = ", mas[m_row-1][m_col-1])
- ############################# Теперь найдём максимум
- max=0
- mm_row=m_row-1
- for i in range(0,mm_row,1):
- for j in range(m_col,cols,1):
- if mas[i][j]>max:
- max=mas[i][j]
- ############################# Выведем искомый результат
- print(max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement