鏈表方面的,?麻煩看得懂的給講下?順便的話帶上注釋?謝謝呀STU?*creat_linkback(STU?*h)//尾插入創(chuàng)建鏈表
{?
?STU?*?H?=?h;
?STU?*?t?=?h;
?STU?*p?=?(STU?*)malloc(sizeof(STU));
?printf?("輸入學(xué)號?姓名\n");
?scanf?("%d?%s",&p->num,p->name);
?if?(H?==?NULL)?{
??H?=?p;
??p?->next?=?NULL;
?}else{
??while(t->next?!=?NULL)
??{
???t?=?t->next;
??}
??t->next?=?p;
??p->next=NULL;
?}
?return?H;
}STU *creat_linkback(STU *h)//尾插入創(chuàng)建鏈表{??STU * H = h;?STU * t = h;?STU *p = (STU *)malloc(sizeof(STU));?printf ("輸入學(xué)號 姓名\n");?scanf ("%d %s",&p->num,p->name);?if (H == NULL)?{??H = p;??p ->next = NULL;?}else{??while(t->next != NULL)??{???t = t->next;??}??t->next = p;??p->next=NULL;?}?return H;}
- 1 回答
- 0 關(guān)注
- 1219 瀏覽
添加回答
舉報(bào)
0/150
提交
取消