Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Global
- Dim i As Integer, j As Integer, n As Integer, temp As Integer
- ' No1
- ' No1: prepare data
- Dim array1() As Double
- Open "input1.txt" For Input As #1
- Input #1, n
- ReDim array1(n - 1)
- For i = 0 To n - 1
- Input #1, array1(i)
- Next i
- ' No1: do the thing
- Dim newArray As Object
- Set newArray = CreateObject("System.Collections.ArrayList")
- For i = 0 To n - 1
- If array1(i) >= 0 And array1(i) <= 2 Then
- newArray.Add array1(i)
- End If
- Next i
- ' No1: print the result
- For i = 0 To newArray.Count - 1
- Debug.Print newArray(i)
- Next i
- Close #1
- ' No2
- ' No2: prepare data
- Dim array2() As Integer
- Open "input2.txt" For Input As #1
- Input #1, n
- ReDim array2(n - 1)
- For i = 0 To n - 1
- Input #1, array2(i)
- Next i
- ' No2: do the thing
- For i = 0 To n \ 2 - 1
- ' n - (n Mod 2) - (i * 2) - это чётные элементы, но в обратном порядке
- temp = array2(n - (n Mod 2) - (i * 2))
- array2(n - (n Mod 2) - (i * 2)) = array2(n - i - 1)
- array2(n - i - 1) = temp
- Next i
- ' No2: print the result
- For i = 0 To n - 1
- Debug.Print array2(i)
- Next i
- Close #1
- ' No3
- ' No3: prepare data
- Dim array3() As Integer
- Open "input3.txt" For Input As #1
- Input #1, n
- ReDim array3(n - 1, n - 1)
- For i = 0 To n - 1
- For j = 0 To n - 1
- Input #1, array3(i, j)
- Next j
- Next i
- ' No3: do the thing
- Dim sum As Integer, count As Integer
- sum = 0
- count = 0
- For i = 0 To n - 2
- For j = i + 1 To n - 1
- If array3(i, j) > 0 Then
- sum = sum + array3(i, j)
- count = count + 1
- End If
- Next j
- Next i
- ' No3: print the result
- Debug.Print count
- Debug.Print sum
Advertisement
Add Comment
Please, Sign In to add comment