SHARE
TWEET

Untitled

a guest Jun 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Sub one()
  3.     Dim Table(8) As Double, _
  4.         TableMin As Integer, _
  5.         TableMax As Integer, _
  6.         WorkCell As Object, _
  7.         SemiSumm As Double, _
  8.         SemiSummAvg As Double, _
  9.         Check As Boolean, _
  10.         n As Integer
  11.              
  12.     Sheets("Лист1").Cells.Clear
  13.     TableMin = 100
  14.     TableMax = 0
  15.     Check = False
  16.  
  17.     For n = 1 To 8
  18.         Table(n) = CInt(100 * Rnd)
  19.         If Table(n) < TableMin Then TableMin = Table(n)
  20.         If Table(n) > TableMax Then TableMax = Table(n)
  21.     Next n
  22.    
  23.     n = 1
  24.     For Each WorkCell In Sheets("Лист1").Range("A1:H1")
  25.         With WorkCell
  26.             .Value = Table(n)
  27.             .Font.ColorIndex = 3
  28.         End With
  29.         n = n + 1
  30.     Next WorkCell
  31.    
  32.     MsgBox "Минимум массива = " & TableMin & vbNewLine & "Максимум массива = " & TableMax
  33.    
  34.     SemiSummAvg = 0
  35.     For n = 1 To 8
  36.         SemiSumm = (Table(n) + TableMax) / 2
  37.         If SemiSumm \ TableMin = SemiSumm / TableMin Then
  38.             SemiSummAvg = SemiSummAvg + Table(n)
  39.             Check = True
  40.         End If
  41.     Next n
  42.     SemiSummAvg = SemiSummAvg / 8
  43.    
  44.     If Check = True Then
  45.         MsgBox "Среднее Элементов по условию = " & SemiSummAvg
  46.     Else
  47.         MsgBox "Нет Элементов по условию (среднее = 0)"
  48.     End If
  49.    
  50.     n = 1
  51.     For Each WorkCell In Sheets("Лист1").Range("A2:H2")
  52.         If n \ 2 = n / 2 Then
  53.             WorkCell.Value = SemiSummAvg
  54.         Else
  55.             WorkCell.Value = Table(n)
  56.         End If
  57.         With WorkCell
  58.             .Font.ColorIndex = 5
  59.         End With
  60.         n = n + 1
  61.     Next WorkCell
  62.    
  63. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top