Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Sub Main()
- Dim c() As Double = {123, -45, 67, 8.7, 123.45, 455.56, 123.45, 455.56, 12.3, -10, 1.1}
- Dim separator As String = "*************"
- Console.WriteLine("Nasz ciąg to: {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}", c(0), c(1), c(2), c(3), c(4), c(5), c(6), c(7), c(8), c(9), c(10))
- Console.WriteLine(separator)
- obliczfunkcje(c)
- obliczsrednia(c)
- Console.ReadKey()
- End Sub
- Public Function obliczfunkcje(ByVal x() As Double) As ArrayList
- Dim suma As New ArrayList
- Dim a As Double
- Dim i As Integer
- Dim separator As String = "**********"
- For i = 0 To x.GetUpperBound(0)
- If x(i) >= 5 Then
- a = Math.Sqrt(x(i) + 10)
- Else
- a = (x(i) - 3) ^ 2
- End If
- suma.Add(a)
- Next
- For i = 0 To suma.Count - 1
- Console.WriteLine("A więc nowa wartość dla {0} miejsca w ciągu to: {1}", i + 1, suma(i))
- Next
- Console.WriteLine(separator)
- Return suma
- End Function
- Public Function obliczsrednia(ByVal y As Array) As Integer
- Dim sredniatab As New ArrayList
- Dim srednia As Integer
- Dim liczba As Integer
- Console.WriteLine("A teraz obliczymy średnią wartość ciągu !")
- For i = 0 To y.GetUpperBound(0)
- If y(i) > 0 Then
- sredniatab.Add(y(i))
- End If
- Next
- liczba = sredniatab.Count
- For i = 0 To sredniatab.Count - 1
- srednia = srednia + sredniatab(i)
- Next
- srednia = srednia / liczba
- Console.WriteLine("Nasza srednia wynosi: {0}", srednia)
- Return srednia
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement