Advertisement
Guest User

Untitled

a guest
Dec 24th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. typedef struct {int jour;int mois;int annee;}date;
  2. typedef struct {char nomfich[15];long taille; date datecreation;}infofich;
  3. typedef struct elt{infofich info; struct elt *svt;} fichier;
  4. typedef struct eltr{char nom_rep[15]; char sous_rep1[15]; char sous_rep2[15]; struct elt *lien;}rep;
  5. typedef struct eltl{rep info; struct eltl *next;} liste;
  6.  
  7. fichier *creation(int m)
  8. { fichier *q,*T=NULL; int j=0;
  9.  
  10. for(j=0;j
  11.  
  12. { q=(fichier *)malloc(sizeof(fichier));    printf("entrez le contenue du fichier: nom,taille \n");
  13.  
  14. scanf("%s %ld",q->info.nomfich,&q->info.taille);
  15.  
  16. printf("entrez la date de creation du fichier:jj,mm,AAAA\n");
  17.  
  18.  scanf("%d %d %d ",&q->info.datecreation.jour,&q->info.datecreation.mois,&q->info.datecreation.annee);
  19.  
  20.  q->svt=T; T=q;}    return(T);}
  21.  
  22. liste *creat_rep(int n)
  23.  
  24. { liste *tete=NULL,*p; int i,m;
  25.  
  26. for (i=0;i
  27.  
  28. { p=(liste *)malloc(sizeof(liste));       printf("entrez le nom du repertoire et des sous repertoires \n");
  29.  
  30. scanf("%s %s %s",p->info.nom_rep,p->info.sous_rep1,p->info.sous_rep2);
  31.  
  32. p->next=tete;     tete=p;  
  33.  
  34. printf("entrez le nombre de fichier dans ce repertoire \n");        scanf("%d",&m);
  35.  
  36. p->info.lien=creation(m); }     return(tete); }
  37.  
  38.  
  39. void affichage(liste *tete,char *ch)
  40.  
  41. { liste *p,*r; fichier *q;
  42.  
  43. for(p=tete;p!=NULL &&(strcmp(p->info.nom_rep,ch)!=0) ;r=p,p=p->next)
  44.  
  45. if (p==NULL) printf("ce repertoire n'existe pas \n");
  46.  
  47. printf("%s %s %s",(r->next)->info.nom_rep,(r->next)->info.sous_rep1,(r->next)->info.sous_rep2);
  48.  
  49. for(q=(r->next)->info.lien;q!=NULL;q=q->svt)
  50.  
  51. printf("%s %ld la date de creation est: %d %d %d",q->info.nomfich,q->info.taille,q->info.datecreation.jour,q->info.datecreation.mois,q->info.datecreation.annee);
  52.  
  53. }
  54.  
  55. int main()
  56.  
  57. { liste *tete=NULL,*p; fichier *q,*r; int n; char ch[15];
  58.  
  59. printf("combien de repertoire voulez-vous crée ?? \n");      scanf("%d",&n);
  60.  
  61.  tete=creat_rep(n);  
  62.  
  63.  printf("entrez le nom du repertoire que vous voulez afficher \n");     scanf("%s",ch);
  64.  
  65.  affichage(tete,ch);      return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement