LANGAGE DE PROGRAMMATION STRUCTUREE

TDI1 2008/2009

Module GESTION_NOTES_STRUCTURES_TDI1CDS Public Structure Stagiaire Dim num As Integer Dim nom As String Dim note1 As Double Dim note2 As Double Dim note3 As Double Dim moyenne As Double Dim classement As Integer Dim decision As String End Structure Dim st As Stagiaire Dim tab() As Stagiaire Sub main() Dim choix As Integer Dim rep As String Do menu() choix = Console.ReadLine() Select Case choix Case 1 tab = saisie(tab) Case 2 Affichage(tab) Case 3 tab = ajouter(tab) Case 4 Dim numsupp As Integer Console.WriteLine("saisir le numero de l'etudiant à supprimer") numsupp = Console.ReadLine tab = supprimer(tab, numsupp) Case 5 Dim nummod As Integer Console.WriteLine("saisir le numero de l'etudiant à modifier les donnees") nummod = Console.ReadLine tab = modifier(tab, nummod) Case 6 Dim numRech As Integer Console.WriteLine("saisir le numero de l'etudiant à rechercher") numRech = Console.ReadLine rechercher(tab, numRech) Case 7 tab = tri(tab) Affichage(tab) Formateur M. Hamid AZZI 1
Complexe de formation Hay Ennahda

LANGAGE DE PROGRAMMATION STRUCTUREE

TDI1 2008/2009

Case 8 End End Select Console.Out.WriteLine("voulez vous continuez(O/N):") rep = Console.ReadLine.ToUpper Loop While rep = "O" End Sub Sub menu() Console.WriteLine("1...SAISIE DES STAGIAIRES.....") Console.WriteLine("2...LISTE DES STAGIAIRES......") Console.WriteLine("3...AJOUTER UN STAGIAIRE......") Console.WriteLine("4...SUPPRIMER UN STAGIAIRE....") Console.WriteLine("5...MODIFIER UN STAGIAIRE.....") Console.WriteLine("6...RECHERCHER UN STAGIAIRE...") Console.WriteLine("7...TRIER ET CLASSER LES STAGIAIRES......") Console.WriteLine("8...QUITTER L'APPLICATION.....") Console.WriteLine(" ...TAPER VOTRE CHOIX.........") End Sub Function saisie(ByRef t() As Stagiaire) As Stagiaire() Dim nb As String Console.WriteLine("donner le nbre de stagiaiares a saiair") nb = Console.ReadLine ReDim Preserve t(nb - 1) For i As Integer = 0 To t.GetUpperBound(0) Console.WriteLine("entrez le numero d'etudiant " & (i + 1) & ":") t(i).num = Console.ReadLine Console.WriteLine("entrez le nom etudiant " & (i + 1) & ":") t(i).nom = Console.ReadLine Console.WriteLine("entrez note1 d'etudiant " & (i + 1) & ":") t(i).note1 = Console.ReadLine Console.WriteLine("entrez note2 d'etudiant " & (i + 1) & ":") t(i).note2 = Console.ReadLine Console.WriteLine("entrez note3 d'etudiant " & (i + 1) & ":") t(i).note3 = Console.ReadLine t(i).moyenne = Math.Round((t(i).note1 + t(i).note2 + t(i).note3) / 3, 2) If t(i).moyenne >= 10 Then t(i).decision = "Admis" Else t(i).decision = "Elimine" Formateur M. Hamid AZZI 2
Complexe de formation Hay Ennahda

LANGAGE DE PROGRAMMATION STRUCTUREE

TDI1 2008/2009

End If Next Return t End Function Function tri(ByRef t() As Stagiaire) As Stagiaire() 'TRI For i As Integer = 0 To t.GetUpperBound(0) - 1 For j As Integer = i + 1 To t.GetUpperBound(0) If t(i).moyenne < t(j).moyenne Then st = t(i) t(i) = t(j) t(j) = st End If Next Next 'CLASSEMENT t(0).classement = "1" For i As Integer = 1 To t.GetUpperBound(0) If t(i).moyenne = t(i - 1).moyenne Then t(i).classement = t(i - 1).classement Else t(i).classement = i + 1 End If Next Return t End Function Sub Affichage(ByRef t() As Stagiaire) For i As Integer = 0 To t.GetUpperBound(0) Console.WriteLine(t(i).num & vbTab & t(i).nom & vbTab & t(i).note1 & vbTab & t(i).note2 & vbTab & t(i).note3 _ & vbTab & t(i).moyenne & vbTab & t(i).classement & vbTab & t(i).decision) Next End Sub Function ajouter(ByRef t() As Stagiaire) As Stagiaire() ReDim Preserve t(t.GetUpperBound(0) + 1) Dim i As Integer = t.GetUpperBound(0) Console.WriteLine("entrez le numero d'etudiant " & (i + 1) & ":") t(i).num = Console.ReadLine Console.WriteLine("entrez le nom etudiant " & (i + 1) & ":") t(i).nom = Console.ReadLine Console.WriteLine("entrez note1 d'etudiant " & (i + 1) & ":") t(i).note1 = Console.ReadLine

Formateur M. Hamid AZZI

3

Complexe de formation Hay Ennahda

LANGAGE DE PROGRAMMATION STRUCTUREE

TDI1 2008/2009 " & (i + 1) & " & (i + 1) &

Console.WriteLine("entrez note2 d'etudiant ":") t(i).note2 = Console.ReadLine Console.WriteLine("entrez note3 d'etudiant ":")

t(i).note3 = Console.ReadLine t(i).moyenne = Math.Round((t(i).note1 + t(i).note2 + t(i).note3) / 3, 2) If t(i).moyenne >= 10 Then t(i).decision = "Admis" Else t(i).decision = "Elimine" End If Return t End Function Function rechercher(ByRef t() As Stagiaire, ByVal numero As Integer) As Integer For i As Integer = 0 To t.GetUpperBound(0) If t(i).num = numero Then Console.WriteLine(t(i).num & vbTab & t(i).nom & vbTab & t(i).note1 & vbTab & t(i).note2 & vbTab & t(i).note3 _ & vbTab & t(i).moyenne & vbTab & t(i).classement & vbTab & t(i).decision) Return i End If Next Console.WriteLine("le stagiaire recherche est introuvable") Return -1 End Function Function supprimer(ByRef t() As Stagiaire, ByVal numero As Integer) As Stagiaire() Dim indice As Integer = rechercher(t, numero) Dim t1(t.GetUpperBound(0) - 1) As Stagiaire Dim j As Integer = 0 If indice <> -1 Then For i As Integer = 0 To t.GetUpperBound(0) If t(i).num <> numero Then t1(j) = t(i) j += 1 End If Next Return t1 End If Return t End Function

Formateur M. Hamid AZZI

4

Complexe de formation Hay Ennahda

LANGAGE DE PROGRAMMATION STRUCTUREE

TDI1 2008/2009

Function modifier(ByRef t() As Stagiaire, ByVal numero As Integer) As Stagiaire() Dim indice As Integer = rechercher(t, numero) If indice <> -1 Then Dim i As Integer = indice Console.WriteLine("entrez le numero d'etudiant :") t(i).num = Console.ReadLine Console.WriteLine("entrez le nom etudiant :") t(i).nom = Console.ReadLine Console.WriteLine("entrez note1 d'etudiant :") t(i).note1 = Console.ReadLine Console.WriteLine("entrez note2 d'etudiant :") t(i).note2 = Console.ReadLine Console.WriteLine("entrez note3 d'etudiant :") t(i).note3 = Console.ReadLine t(i).moyenne = Math.Round((t(i).note1 + t(i).note2 + t(i).note3) / 3, 2) If t(i).moyenne >= 10 Then t(i).decision = "Admis" Else t(i).decision = "Elimine" End If End If Return t End Function End Module

Formateur M. Hamid AZZI

5

Complexe de formation Hay Ennahda

Sign up to vote on this title
UsefulNot useful