反转链表

来源:互联网 发布:如何制作云免流软件 编辑:程序博客网 时间:2024/06/06 03:24
给定如下C程序:
1
2
3
4
5
6
7
8
9
10
11
12
13
typedefstruct node_s{
    intitem;
    structnode_s* next;
}node_t;
voidreverse_list(node_t* head)
{
    node_t* n=head;
    head=NULL;
    while(n){
    _________               
    }
    returnhead;
 }
空白处填入以下哪项能实现该函数的功能?
  • node_t* m=head; head=n; head->next=m; n=n->next;
  • node_t* m=n; n=n->next; m->next=head; head=m;
  • node_t* m=n->next; n->next=head; n=m; head=n;
  • head=n->next; head->next=n; n=n->next;
  • 答案B
0 0
原创粉丝点击