Advertisement
SilLAwNeD

nf16 tp3 main.c

Nov 14th, 2018
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.64 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include "tp3.h"
  5.  
  6. int main(void){
  7.     char choixMenu = '\0';
  8.     float note;
  9.     char matiere[20], prenom[26], nom[26];
  10.     int idEtu;
  11.     T_Etudiant etudiant;
  12.     T_ListeEtu listeEtu = NULL;
  13.  
  14.     do {
  15.         afficherMenu();
  16.         switch (choixMenu) {
  17.         case '1':
  18.             if (listeEtu == NULL){
  19.               printf("ID : ");
  20.               scanf("%d", &idEtu);
  21.               printf("Prenom : ");
  22.               scanf("%s", prenom);
  23.               printf("Nom : ");
  24.               scanf("%s", nom);
  25.               listeEtu = creerEtudiant(idEtu, nom, prenom);
  26.               printf("Pour finaliser la creation, entrer une matiere : ");
  27.               scanf("%s", matiere);
  28.               do{
  29.                 printf("Note entre 0 et 20 : ");
  30.                 scanf("%f", &note);
  31.               } while(note < 0 || note > 20);
  32.               listeEtu = ajouterNoteEtu(note, matiere, idEtu, listeEtu);
  33.               break;
  34.             }
  35.             system("clear");
  36.             printf("La liste n'est pas vide, utilisez l'option 2\n");
  37.             sleep(2);
  38.             break;
  39.         case '2':
  40.             system("clear");
  41.             do{
  42.               printf("Note entre 0 et 20 : ");
  43.               scanf("%f", &note);
  44.             } while(note < 0 || note > 20);
  45.             printf("Matiere : ");
  46.             scanf("%s", matiere);
  47.             printf("ID : ");
  48.             scanf("%d", &idEtu);
  49.             listeEtu = ajouterNoteEtu(note, matiere, idEtu, listeEtu);
  50.             break;
  51.         case '3':
  52.             system("clear");
  53.             printf("Matiere : ");
  54.             scanf("%s", matiere);
  55.             printf("ID : ");
  56.             scanf("%d", &idEtu);
  57.             listeEtu = supprimerNoteEtu(matiere, idEtu, listeEtu);
  58.             break;
  59.         case '4':
  60.             afficherListeEtu(listeEtu);
  61.             sleep(2);
  62.             break;
  63.         case '5':
  64.             if (listeEtu != NULL){
  65.               afficherClassement(listeEtu);
  66.             }
  67.             break;
  68.         case '6':
  69.             if (listeEtu != NULL){
  70.               printf("Matiere : ");
  71.               scanf("%s", matiere);
  72.               afficherSousListes(listeEtu, matiere);
  73.             }
  74.             break;
  75.         default:
  76.             printf("Veuillez choisir un numero entre 1 et 7.\n");
  77.             break;
  78.         }
  79.  
  80.     } while ((choixMenu = getchar()) != '7');
  81.  
  82.     while(listeEtu != NULL){
  83.       listeEtu = supprimerNoteEtu(listeEtu->notes->matiere, listeEtu->id, listeEtu);
  84.     }
  85.     system("clear");
  86.     printf("Mémoire libérée\n");
  87.  
  88.     return EXIT_SUCCESS;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement