السلام عليكم ورحمة الله وبركاته
كود PHP:
#include <stdio.h>
#include <stdlib.h>
int main()
{
/*typedef struct Maillon Maillon;*/
struct Maillon {
int val;
struct Maillon *suiv;
};
struct Maillon *Allouer() {
return ((struct Maillon *) malloc( sizeof(struct Maillon)));
};
struct Maillon *Suivant ( struct Maillon *p)
{
return( p->suiv );
};
void Aff_Val( struct Maillon *p, int v )
{
p->val = v;
}
void Aff_Adr( struct Maillon *p, struct Maillon *q )
{
p->suiv = q;
}
int Valeur( struct Maillon *p)
{
return (p->val);
}
struct Maillon *p;
struct Maillon *q;
struct Maillon *Tete;
int i,Nombre_des_elements;
int val; /* La valeur peut etre de type qlq : ici un entier */
Tete=NULL;
p=NULL;
printf("Veuillez introduire le nombre des elements dans la liste ==>");
scanf("%d",&Nombre_des_elements);
for ( i=1 ; i<=Nombre_des_elements ; i++)
{
printf("LA VALEUR DU MAILLON %d est :",i);
scanf("%d",&val);
q=Allouer();
Aff_Val(q,val);
Aff_Adr(q,NULL);
if ( Tete != NULL )
{
Aff_Adr(p,q);
}
else
{
Tete=q;
}
p=q;
}
p=Tete;
i=0;
while ( (p != NULL) && (i<Nombre_des_elements) )
{
printf("%d\n",Valeur(p));
p= Suivant(p);
i++;
}
return 0;
}
تم تغيير
الى
لانك allouer في برنامجك كتبتها على شكل دالة لديها قيمة مرجعة وليست procedure
---------------------