Advertisement
fabis_sparks

IvanPythonOS

Dec 4th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import random
  2. ############################# ����� ���������� ����� � ��������
  3. rows=int(input('Size of matrix: '))
  4. ############################# ����������� ������ ��������� �������
  5. treshold=int(input("Input treshold: "))
  6. #r=random.randint(1,100)
  7. mas = []
  8. nec_mas=[]
  9. for i in range(rows):
  10.     mas.append([])
  11.     for j in range(rows):
  12.         r = random.randint(1,100)  
  13.         mas[i].append(r)
  14.        
  15. sum=0
  16. masn=1
  17. output=0
  18. x=0
  19. print("Show us a randomized array")
  20. for i in range(rows):
  21.     print(mas[i], "\n")
  22. print("Let's start to view necessary arrays")
  23. for i in range(rows):
  24.      nec_mas.append([])
  25.      for j in range(rows):
  26.         if(output==1):
  27.             print("Array #",nec_mas,": ", end='')
  28.         if(sum<treshold or sum==treshold):
  29.             nec_mas[x].append(mas[i][j])
  30.             output=0
  31.             sum=sum+mas[i][j]
  32.             print(mas[i][j]," ", end='' )
  33.         else:
  34.             x=x+1
  35.             print("\nSum: ", sum);
  36.             print("====================")
  37.             #masn=masn+1
  38.             sum=0
  39.             output=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement