Advertisement
mmouhib

Correction Revision algo Arbre

Jun 8th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 3) procedure ArbEq (DonRes A:Arbre ,DonRes Fe:FEtudiant , DonRes n:entier)
  2. variable E : Etudiant;
  3. P : Arbre;
  4.  
  5. Debut
  6. Si (n = 0) alors A <-- NIL;
  7. Sinon
  8. Allouer (p);
  9. Lire (Fe,E);
  10. P@.E <-- E;
  11. ArbEq(A@.gche,Fe,n/2);
  12. ArbEq(A@.dte,Fe,(n+1)-(2-1));
  13. Fin Si
  14. Fin
  15.  
  16. 4) Parcours Infixé l'affichage
  17. Procedure Afficher (DonRes A: Arbre)
  18. debut
  19. Si (A<>NIL) Alors
  20. Afficher (A@.gche);
  21. Ecrire (A@.E.nom);
  22. Ecrire (A@.E.prenom):
  23. Afficher (A@.dte);
  24. Fin Si
  25. Fin
  26.  
  27. 5) Fonction CreAbr (DonRes A:Arbre) : Arbre
  28. Variable R: Arbre;
  29. Debut
  30. Si (A<>NIL) Alors
  31. CreAbr <-- CreaAbr(A@.gche)
  32. InsAbr(R,A@.E)
  33. CreAbr <-- CreAbr(A@.dte);
  34. Fin Si
  35. fin
  36.  
  37.  
  38. 5.1) Procedure InsArb (DonRes A: Arbre, x : Etudiant)
  39. variable q : Arbre
  40. Debut
  41. Si (A = NIL) alors
  42. Allouer(q)
  43. q@.E <-- x
  44. q@.gche<-- NIL
  45. q@.dte <-- NIL
  46. P<--q
  47. Sinon
  48. Si (x.moy > P@.E.moy) alors
  49. InsAbr(P@.dte,x)
  50. Sinon
  51. InsAbr(P@.gche,x)
  52. FinSi
  53. Fin
  54.  
  55. 6) Affichage / Order Moyenne
  56. Procedure AfficheMoy(DonRes A: Arbre)
  57. debut
  58. Si (A<>Nil) Alors
  59. AfficheMoy(A@.dte)
  60. ecrire(A@.E.ide,A@.E.moy)
  61. AfficheMoy(A@.gche)
  62. FinSi
  63. fin
  64.  
  65. 7) Algorthme principal
  66. Algorithme Menugen
  67. variable x: entier
  68. Fe : FEtudiant
  69. A,Abr : Arbre
  70. debut
  71. Ecrire ('Le nbr d'etudiant est = ',nbret(Fe))
  72. x <-- nbret(Fe)
  73. ouvrir (Fe,lec)
  74. ArbEq (A,x,Fe)
  75. Abr <-- CreAbr (A)
  76. AfficheMoy (Abr)
  77. Fermer(Fe)
  78. Fin
  79.  
  80.  
  81. 8) Type
  82. Liste = @cellule
  83. cellule = enregistrement
  84. info : entier
  85. suiv : Liste
  86. File = enregistrement
  87. tete : Liste
  88. queue : Liste
  89. Procedure Crefles(DonRes A: Arbre, Res F1:File , Res F2 : File)
  90. debut
  91. Si (A<> NIL)
  92. Alors
  93. Crefiles (A@.gche,F1,F2)
  94. Si (A@.E.moy >=10 )
  95. Alors Crefiles (F1, A@.E.moy)
  96. Sinon
  97. Enfiler (F2,A@.E.moy)
  98. FinSi
  99. Crefiles (A@.dte,F1,F2)
  100. FinSi
  101. Fin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement