#include
typedef struct listNode listNode;
typedef listNode *List;
typedef int itemType;
struct listNode{
itemType item;
List next;
};
List newNode(itemType v);
List insertHead(itemType v, List l);
void stampa(List);
main(){
List l=NULL;
int i;
l=insertHead(1,l);
l=insertHead(2,l);
stampa(l);
}
List newNode(itemType v){
List l;
l=malloc(sizeof(List));
l->item=v;
l->next=NULL;
return l;
}
List insertHead(itemType v, List l){
List ptr;
ptr=newNode(v);
ptr->next=l;
return ptr;
}
void stampa(List l){
if(l==NULL){printf("null\n");exit(0);}
printf("%d",l->item);
stampa(l->next);
}
Nessun commento:
Posta un commento