Questo topic e' stato chiuso dal moderatore.
20/01/10 20:29
oretovalley
Ciao a tutti, questo mio topic, ha due scopi, prima di tutto chiarirmi un dubbio, se stampo in msgbox tutti gli anagrammi di 8 lettere, riesco a stamparli tutti 40320, ma messi su listbox si blocca il software, potrebbe essere un limite della stessa come numero di righe?
Inoltre rilascio l'algoritmo funzionante fino a 10 caratteri, max 7 per essere messi in una listbox, 10 stampati in una msgbox.
spero che possiate chiarire questo mio dubbio
Inoltre rilascio l'algoritmo funzionante fino a 10 caratteri, max 7 per essere messi in una listbox, 10 stampati in una msgbox.
Public Class Form1 Dim lettere_parola() As Char Dim anagrammi() As String Dim lettera() As Integer Dim fattoriale As Integer Dim trovato As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Clear() ReDim lettera(UBound(lettere_parola)) ReDim anagrammi(fattoriale) Dim number As New Random For cont As Integer = 0 To fattoriale - 1 For i As Integer = 0 To UBound(lettere_parola) trovato = False While trovato = False lettera(i) = number.Next(1, UBound(lettere_parola) + 2) For j As Integer = 0 To UBound(lettere_parola) If lettera(i) = lettera(j) And j <> i Then trovato = True End If Next If trovato = True Then trovato = False Else trovato = True End If End While anagrammi(cont) += TextBox1.Text(lettera(i) - 1) Next trovato = False For i As Integer = 0 To cont If anagrammi(cont) = anagrammi(i) And i <> cont Then trovato = True Exit For End If Next If trovato <> True Then ListBox1.Items.Add(anagrammi(cont)) End If anagrammi(cont) = "" If trovato = True Then cont -= 1 End If For i As Integer = 0 To UBound(lettere_parola) lettera(i) = 0 Next Next End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim num_lettere As Integer = 0 lettere_parola = TextBox1.Text.ToCharArray For i As Integer = 0 To UBound(lettere_parola) trovato = False For j As Integer = 0 To UBound(lettere_parola) If TextBox1.Text(i) = TextBox1.Text(j) And i <> j Then trovato = True End If Next If trovato = False Then num_lettere += 1 End If Next fattoriale = 1 For i As Integer = num_lettere To 1 Step -1 fattoriale *= i Next End Sub End Class
spero che possiate chiarire questo mio dubbio
aaa