Skip to content
Snippets Groups Projects
Commit 5c568526 authored by DARWICH ALI's avatar DARWICH ALI
Browse files

m

parent 841c58c7
No related merge requests found
#include "Listecirculaire.h"
Listecir listenouv_circ(){
return NULL ;
}
Listecir adjt_circ(Listecir l , S x){
Listecir l1 = MALLOC(StrListecir) ;
l1->v = x ;
Listecir l2 = l;
if(l == NULL){
l1->s = l1 ;
return l1 ;
}
else{
l1->s = l2 ;
//l2 = l ;
while(l2->s != l){
l2 = l2->s ;
}
l2->s = l1 ;
return l1 ;
}
}
Listecir sup_circ(Listecir l ){
Listecir l1 = l ;
if( l == NULL){
return listenouv_circ();
}
else{
Listecir temp = l ;
free(l1);
while(temp->s != l){
temp = temp->s ;
}
l = l->s ;
temp->s = l ;
return l ;
}
}
S tete_circ(Listecir l){
return l->v ;
}
Nat lgr(Listecir l ){
Listecir l1 = l ;
if(l == NULL ){
return 0 ;
}
else{
return (l1 == l1->s) ? 1 : 1 + lgr(sup_circ(l)) ;
}
}
bool vide(Listecir l) ;
bool app(Listecir l , S x) ;
File added
#ifndef __LISTECIRCULAIRE__
#define __LISTECIRCULAIRE__
#include "base.h"
#define S Nat
typedef struct strlistecir{ S v ; struct strlistecir *s ;}StrListecir , *Listecir ;
Listecir listenouv_circ();
S tete_circ(Listecir l);
Listecir adjt_circ(Listecir l , S x);
Listecir sup_circ(Listecir l ) ;
Nat lgr(Listecir l );
bool vide(Listecir l) ;
bool app(Listecir l , S x) ;
#endif
\ No newline at end of file
#include "Listecirculaire.h"
int main(){
Listecir l = listenouv_circ();
for(int i = 0; i < 5 ; i++){
l = adjt_circ(l , i);
printf("%d " , tete_circ(l));
}
printf("\n");
Listecir l1 = l;
//printf("tete = %d\n" , tete_circ(l));
l = sup_circ(l);
printf("tete = %d\n" , tete_circ(l));
l1 = l ;
printf("long : %d\n", lgr(l));
printf("tete = %d\n" , tete_circ(l));
for(int i = 0 ;i < (int)lgr(l); i++ ){
printf("%d ", tete_circ(l1));
l1 = l1->s ;
}
printf("\n");
return 0 ;
}
\ No newline at end of file
File added
No preview for this file type
/*
#include "ListeSimple.h"
......@@ -104,6 +105,7 @@ int main(){
}
printf("\n");
*/
/*
return 0;
}
\ No newline at end of file
}
*/
\ No newline at end of file
No preview for this file type
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment