Avez-vous une question? (216) 97 656 803 hajjriadh@gmail.com
VB.Net

VB.Net: Correction des exercices tableaux et matrices 12

Un cours complet pour maîtriser VB.Net: Correction des exercices tableaux et matrices 12.

0 chapitres 0 QCM Accès gratuit

12 Correction Exercice 12

Module exercice12

    Dim mots As Char()
    Dim texte As String
    Dim texte_origine As String
    Sub Main(args As String())
        initialisationTableau()
        affichageTableau()
        If testPalindrome(texte) = True Then
            System.Console.WriteLine("La chaîne: {0} est un palindrome.", texte_origine)
        Else
            System.Console.WriteLine("La chaîne: {0} n'est pas un palindrome.", texte_origine)
        End If
    End Sub
    Public Sub affichageTableau()
        For i As Integer = 0 To mots.Length - 1
            System.Console.WriteLine(mots(i))
        Next
    End Sub
    Public Sub initialisationTableau()
        System.Console.WriteLine("Entrez une ligne de texte (max.100 caractères)")
        texte_origine = System.Console.ReadLine()
        texte = texte_origine.ToLower()
        texte = texte.Replace(" ", "")
        mots = texte.ToCharArray()
    End Sub
    Public Function testPalindrome(texte As String) As [Boolean]
        Dim resultat As [Boolean] = True
        Dim test_mots As Char() = texte.ToCharArray()
        For i As Integer = 0 To mots.Length - 1
            If mots(i) <> test_mots(test_mots.Length - i - 1) Then
                resultat = False
                Exit For
            End If
        Next
        Return (resultat)
    End Function


End Module



Exercice d’application les tableaux