Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. Rem Attribute VBA_ModuleType=VBADocumentModule
  2. Option VBASupport 1
  3. Sub qq()
  4. Dim a(), m, n As Integer
  5. Dim counterZero, totalCounter As Integer
  6. Dim NumberN As Integer
  7. Dim masodin() As Integer
  8. n = CInt(InputBox("Введите размерность строк:"))
  9. m = CInt(InputBox("Введите размерность столбцов:"))
  10. ReDim a(n, m)
  11. Selection.TypeText ("Матрица:" + Chr(13))
  12. For i = 1 To n
  13. For j = 1 To m
  14. a(i, j) = CInt(Rnd() * 100) - 50
  15. Selection.TypeText (CStr(a(i, j)) + Chr(9))
  16. Next j
  17. Selection.TypeParagraph
  18. Next i
  19. Selection.TypeParagraph
  20. counterZero = 0
  21. totalCounter = 0
  22.  
  23. For i = 1 To n
  24. For j = 1 To m
  25. If (a(i, j) = 0) Then
  26. counterZero = counterZero + 1
  27. End If
  28. Next j
  29. If (counterZero = 0) Then
  30. totalCounter = totalCounter + 1
  31. counterZero = 0
  32. End If
  33. Next i
  34.  
  35. Dim NumberProv As Integer
  36. NumberN = 0
  37. NumberProv = 0
  38.  
  39. For i = 1 To m
  40. For j = 1 To n
  41. If (a(i, j) > 0 And NumberProv = 0) Then
  42. NumberN = i
  43. NumberProv = 1
  44. Exit For
  45. End If
  46. Next j
  47. Next i
  48.  
  49. Dim t, t1, r, t2 as Integer
  50. Dim k, f As Integer
  51. r = 0
  52. for i = 0 To n
  53. for j = 0 to n
  54. t2=a(i,j)
  55. a(i,j)=0
  56. for k = 0 To n
  57. for f = 0 To n
  58. if(t2 = a(k,f)) then
  59. t = a(k,f)
  60. end if
  61. if(t2 <> a(k,f)) then
  62. r=r+1
  63. end if
  64. Next f
  65. if(t1>t) then
  66. t = t1
  67. end if
  68. Next k
  69. t1=t
  70. a(i,j)=t2
  71. Next j
  72. Next i
  73.  
  74. Selection.TypeText ("Кол-во строк без 0: " + Str(totalCounter))
  75. Selection.TypeParagraph
  76. Selection.TypeText ("Номер первой из строк, содержащих хотя бы один положительный элемент: " + Str(NumberN))
  77. Selection.TypeParagraph
  78. Selection.TypeText ("max из чисел встречающихся в матрице более 1 раза: " + Str(t))
  79. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement