struct_list_sign_my_name.c 傷城~ 2022-09-24 00:22 53阅读 0赞 #include<stdio.h> \#define null 0; struct person \{ char name\[\]; int id; char adress\[\]; struct person \* next; struct person \* last; \} //one-direction struct list struct person \* create(int num) \{ int i; struct person \* p,q,head; head=p=q=(struct person \* )malloc(sizeof(struct person)); p->next=p->last=null; if(num>1) \{ for(i=2;i<=num;i++)//i represents number of crunodes \{ p=(struct person \* )malloc(sizeof(struct person)); p->last=q; q->next=p; //import the imformation of people q=p; \} \} p->next=null; return head; \} void finder(struct person \* p) \{ if(p->name hasn not been visited) \{ //sign my name p=p->next; finder(p); \} else \{ p=p->last; //find another person if (can not find) exit (0); \} \} void main() \{ int num; struct person \* head; printf("Enter the number of person you want to visit:\\n"); scanf("%d",&num); head=create(num); finder(head); printf("It's the end!\\n Work more tomorrow!\\n"); \} 收藏于 2008-05-25
还没有评论,来说两句吧...