Paste: dd

Author: dd
Mode: vbscript
Date: Thu, 3 Dec 2009 21:16:35
Plain Text |
Public Class Form1
 
    Function naLiczby(ByVal ciag As String) As Integer()
        Dim ciagPociety As String() = ciag.Split(" ")
        Dim tablicaPocietych As Integer() = New Integer(ciagPociety.Length - 1) {}
 
        For i As Integer = 0 To ciagPociety.Length - 1
            If ciagPociety(i) <> "" Then tablicaPocietych(i) = CInt(ciagPociety(i))
        Next
 
        Return tablicaPocietych
    End Function
 
    Function wTablicy(ByVal liczby As Integer(), ByVal szukana As Integer) As Boolean
        For i As Integer = 0 To liczby.Length - 1
            If liczby(i) = szukana Then Return True
        Next
 
        Return False
    End Function
 
    Function ileUnikalnych(ByVal liczby As Integer()) As Integer
        Dim unikalne As Integer() = {}
        Dim rozmiar As Integer
 
        For i As Integer = 0 To liczby.Length - 1
            If Not wTablicy(unikalne, liczby(i)) Then
                rozmiar += 1
                System.Array.Resize(unikalne, rozmiar)
                unikalne(unikalne.Length() - 1) = liczby(i)
            End If
        Next
 
        Return unikalne.Length
    End Function
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = ileUnikalnych(naLiczby(TextBox1.Text))
    End Sub
 
 
End Class

New Annotation

Summary:
Author:
Mode:
Body: