You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
4.3 KiB

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sae1-02.h"
// général
// f enregistrement
/*
// Partie 1
void affichageVilleIUT() {
printf("%s\t%s\t%d\t%s")
}
int rechercheVille() {
}
VilleIUT lire(FILE * fe) {
VilleIUT v;
fscanf(fe, "%s", V.ville);
fscanf(fe, "%s", v.Idept->departement);
fscanf(fe, "%d", v.Idept->nbplace);
fgets(v.Idept->responsable, 31, fe);
v.Idept->responsable[strlen(v.Idept->responsable)-1] = '\0';
return v;
}
*/
// Partie 2
/*
( beaucoup de donnée a traité n(min 10 ; max ?)*nb candidat donc faire attention )
possibilité pour le candidat pouvoir <! table = (modifier - ajouter - supp) !>
- nb candidats (général en haut du doss)
- num candidat
- nom candidat
- prénom candidat
- liste des notes (moyenne dans le sens précis -- math francais anglais et matière spé)
|<= nb choix
|=>recurrence :
|- ville
|- département
|- décision ( admis - 1 /attente 0 default /refusé -2 )
|- validation candidat ( 0 default / -1 refus de ce choix / 2 accepte )
doit venir du menu car sinon pas de transport pour la part 3,
le tableau de pointeur qui contient listcandinfo et listcand,
combien de fonctionnalité en combien de fonction ...
-charger fichier
-modifier choix
-ajouter choix
-supp choix
-afficher les infos d'un cand
-tout cand d'un dep (ordre alphabétique)
-enregistrer fichier
charger -- recup :
-nb candi
-listcandinfo
-nb choix
-listcand
*/
Listchoixdept listchoixdeptvide(void){
return NULL;
}
Listchoixdept inserercarte(Listchoixdept c, FILE *fe){
Maillonchoix* cc;
cc = (Maillonchoix*)malloc(sizeof(Maillonchoix*));
if(cc==NULL){printf("<! pb malloc in ajoutercarte !>\n");exit(1);}
fscanf(fe, "%s %s %d %d", cc->Ville, cc->dep, &cc->decision, &cc->validation);
cc->suivant=c;
return cc;
}
Listchoixdept lireChoix(FILE *fe, int nbchoix){
int i=0;
int decision, validation;
char Ville[21], dep[21];
Listchoixdept c, temp;
c = listchoixdeptvide();
for(i=0; i<nbchoix; i++){
c = inserercarte(c, fe);
}
return c;
}
listetuinfo lireEtu(FILE *fe){
listetuinfo b;
int i;
fscanf(fe, "%d %s %s %d %d %d %d %d", &b.numeroetu, b.nometu, b.prenometu, &b.notes[0], &b.notes[1], &b.notes[2], &b.notes[3], &b.nbchoix);
b.lchoixdept = lireChoix(fe, b.nbchoix);
return b;
}
int chargeretudiant(char nomFich[], listetuinfo *tetu[], int tmax){
int i=0, nbetu;
printf("bonjour");
listetuinfo a;
FILE *fe;
fe = fopen( nomFich, "r");
if(fe==NULL){printf("<! pb ouverture fichier in chargeretudiant !>\n");return-1;}
fscanf(fe, "%d", &nbetu);
for(i=0; i<nbetu; i++){
if(i==tmax){printf("<! erreur fichier in chargeetudiant !>");fclose(fe);return-1;}
printf("bonjour");
tetu[i] = (listetuinfo*)malloc(sizeof(listetuinfo));
if(tetu[i]==NULL){printf("<! pb malloc in chargeretudiant !>\n");fclose(fe);return-1;}
a = lireEtu(fe);
*tetu[i] = a;
i++;
}
fclose(fe);
return nbetu;
}
void affichage(Listchoixdept c){
if(c==NULL){printf("}\n");return;}
printf("%s %s %d %d", c->Ville, c->dep, c->decision, c->validation);
if(c->suivant==NULL){affichage(c->suivant);}
else{
printf(",");
affichage(c->suivant);
}
}
void affichageetu(listetuinfo a){
printf("%d\n%s %s\n", a.numeroetu, a.nometu, a.prenometu);
printf("mathématique : %d\n", a.notes[0]);
printf("français : %d\n", a.notes[1]);
printf("anglais : %d\n", a.notes[2]);
printf("matière spé : %d\n", a.notes[3]);
}
void test1(void){
listetuinfo *tetu[5000];
int j, i, nb;
char nomFich[20];
strcpy( nomFich, "candidature.txt");
nb = chargeretudiant(nomFich, tetu, 5000);
printf("bonjour1");
for(j=0; j<nb; j++){
affichageetu(*tetu[j]);
for(i=0; i<tetu[j]->nbchoix; i++){
printf("carte %d={", i+1);
affichage(*tetu[j]->lchoixdept);
}
}
}
// Partie 3
// Partie 4
// Général (menu et ce qui en ai relié)
/*
questionadmin(){
printf("\nQuel numéro détudiant ?\n==>");
scanf("%d%*c", &choix);
printf("\n");
}
int menu(void){
//charger
int i=0, choix;
while(i!=1){
printf("\n\tmenu\n\n");
printf("1\tutilisateur\n");
printf("2\tadmin\n");
printf("3\tresponsable d'admission\n");
printf("\nQuel est votre choix ?\n==>");
scanf("%d%*c", &choix);
printf("\n");
if(choix==1){
}
if(choix==2){
}
if(choix==3){
}
if(choix<1 || choix>6){
printf("mauvaise saisie\n");
}
}
//enregister
return 1;
}
*/