17 Mars
This commit is contained in:
		| @@ -11,6 +11,59 @@ struct graphe{ | ||||
|  | ||||
| typedef struct graphe graphe; | ||||
|  | ||||
| struct file { | ||||
|   	int data; | ||||
|   	struct file* succ; | ||||
| }; | ||||
|  | ||||
| typedef struct file fifo; | ||||
|  | ||||
| fifo* enqueue(fifo **fi,int v){ | ||||
|   fifo *nf=malloc(sizeof(fifo)); | ||||
|   nf->data=v; | ||||
|   nf->succ=*fi; | ||||
|   return nf; | ||||
| } | ||||
|  | ||||
| int dequeue(fifo **fi){ | ||||
|   fifo *lect=*fi; | ||||
|   if(lect->succ==NULL){ | ||||
|     int res=lect->data; | ||||
|     *fi=NULL; | ||||
|     return res; | ||||
|   } | ||||
|   while(lect->succ->succ!=NULL){ | ||||
|     lect=lect->succ; | ||||
|   } | ||||
|   int res=lect->succ->data; | ||||
|   fifo *temp=lect->succ; | ||||
|   lect->succ=NULL; | ||||
|   free(temp); | ||||
|   return res; | ||||
| } | ||||
| int empty(fifo *fi){ | ||||
|   return fi==NULL; | ||||
| } | ||||
|  | ||||
| void afficheFile(fifo *fi){ | ||||
| 	fifo *affichage=malloc(sizeof(fifo)); | ||||
| 	affichage=fi; | ||||
| 	while(affichage->succ!=NULL){ | ||||
| 		printf("%hu ",affichage->data); | ||||
| 		affichage=affichage->succ; | ||||
| 	}free(affichage); | ||||
| } | ||||
|  | ||||
| fifo* fileVoisins(graphe g,int v){ | ||||
| 	fifo *res=malloc(sizeof(fifo)); | ||||
| 	int i; | ||||
| 	for(i=0;i<g.ordre;i++){ | ||||
| 		if(g.adj[i][v]==1){ | ||||
| 			enqueue(&res,g.adj[i][v]); | ||||
| 		} | ||||
| 	} return res; | ||||
| } | ||||
|  | ||||
| graphe creergraphe(int ord,int or){ | ||||
| 	int i; | ||||
| 	int j; | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| #include <stdlib.h> | ||||
| #include "FichierDef.h" | ||||
|  | ||||
|  | ||||
| int main(int argc, char const *argv[]){ | ||||
| 	graphe Graphe; | ||||
| 	int connexe; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user