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

VB.Net: Correction des exercices tableaux et matrices 15

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

0 chapitres 0 QCM Accès gratuit

15 Correction Exercice 15

Module exercice15
    Dim tableau As Integer(,) = New Integer(9, 7) {}
    Sub Main(args As String())
        remplirTableau()
        AffichageTab()
        tabMini()
        tabMax()
        'TriTab();
        Console.WriteLine("La somme est: " & tabSomme() & " ")
        Console.WriteLine("La moyenne est: " & (tabSomme() / tableau.Length))
    End Sub
    Private Sub remplirTableau()
        Dim rnd As New Random()
        ' affectation de valeurs entières, pris au hasard entre 1 et 100, au tableau
        For i As Integer = 0 To 9
            For j As Integer = 0 To 7
                tableau(i, j) = rnd.Next(1, 101)
            Next
        Next
    End Sub
    Private Sub AffichageTab()
        'affichage des valeurs du tableau
        For i As Integer = 0 To 9
            For j As Integer = 0 To 7
                Console.WriteLine("Contenu de la case [{0},{1}] est : {2}", i, j, tableau(i, j))
            Next
        Next
    End Sub
    Private Sub tabMini()
        Dim min As Integer = 101
        'Recherche de minimum
        For i As Integer = 0 To 9
            For j As Integer = 0 To 7
                If min < tableau(i, j) Then
                    min = tableau(i, j)
                End If
            Next
        Next
        Console.WriteLine("Le minimum est: " & min & " ")
    End Sub
    Private Sub tabMax()
        Dim max As Integer = 0
        'Recherche de maxmimum
        For i As Integer = 0 To 9
            For j As Integer = 0 To 7
                If max < tableau(i, j) Then
                    max = tableau(i, j)
                End If
            Next
        Next
        Console.WriteLine("Le maximum est: " & max & " ")
    End Sub
   allez à suite........................
End Module

Suite

 Private Function tabSomme() As Double
        Dim somme As Integer = 0
        For i As Integer = 0 To 9
            For j As Integer = 0 To 7

                somme += tableau(i, j)
            Next
        Next
        Return somme
    End Function

Exercice d’application les tableaux