编写一子程序,将一链表倒序,即使链表表尾变表头,表头变表尾
编辑: 面试啦 发布时间: 2023-11-01 05:44:28
解: struct example *reverse(head)
struct example *head;
{
struct example p1,p2;
p1=(struct example *)malloc(size);
p1->key=head->key;
p1->next=NULL;
while(head->next!=NULL)
{
p2=head->next;
head->next=(head->next)->next;
p2->next=p1->next;
p1->next=p2;
}
head=p1;
return(head);
}
struct example *head;
{
struct example p1,p2;
p1=(struct example *)malloc(size);
p1->key=head->key;
p1->next=NULL;
while(head->next!=NULL)
{
p2=head->next;
head->next=(head->next)->next;
p2->next=p1->next;
p1->next=p2;
}
head=p1;
return(head);
}
词条:c面试题
上一篇:凌阳科技股份有限公司C++程序员面试题笔试题 下一篇:C++面试题:关于链表和指针
面试题库导航
- C++面试题
- JAVA面试题
- Oracle面试题
- MySQL面试题
- Linux面试题
- 网络工程师面试题
- 网管面试题
- 软件工程师面试题
- PHP面试题
- .net面试题
- 软件测试面试题
- EJB面试题
- Spring面试题
- Javascript面试题
- Python面试题
- QTP面试题
- Servlet面试题
- J2EE面试题
- Database面试题
- ASP面试题
- Unix面试题
- Loadrunner面试题
- 通信面试题
- 嵌入式面试题
- Ruby面试题
- Delphi面试题
- Mobile开发面试题
- SOA面试题
- JAVA面试题面试题
- 研发工程师面试题
- 软件架构师面试题
- 系统工程师面试题
- Android面试题
- JAVA程序员
- C#面试题