链表翻转
来源:互联网 发布:斑马网络计划破解软件 编辑:程序博客网 时间:2024/06/05 06:51
#include<iostream>using namespace std;typedef struct head{int a;struct head *next;}NLode;void intial(NLode **head){*head=(NLode *)malloc(sizeof(NLode));(*head)->next=NULL;}void insert(NLode *head,int a){NLode *p,*q;p=head;q=(NLode*)malloc (sizeof(NLode));while(p->next!=NULL){p=p->next;}q->a=a;q->next=p->next;p->next=q;}NLode * reserve(NLode *head){NLode *p,*q,*r;p=head;q=head->next;p->next=NULL;while(q!=NULL){r=q;q=q->next;r->next=p;p=r;}return r;}void printSL(NLode *head){NLode *p;p=head->next;while(p!=NULL){cout<<p->a<<" ";p=p->next;}}void printSLR(NLode *head){while(head!=NULL&&head->next!=NULL){cout<<head->a;head=head->next;}}void main(){NLode *head1,*head2,*head3,*head4; intial(&head1);int a,b,num=0,i;cin>>a;for(i=0;i<a;i++){cin>>num;insert(head1,num);} cout<<"A:"<<endl;printSL(head1);cout<<endl;cout<<"B:"<<endl;head4=reserve(head1);printSLR(head4);system("pause");}
0 0
- 无情链表的创建,,翻转翻转
- 链表翻转程序
- 链表翻转
- 链表翻转
- 链表翻转
- 翻转单向链表
- 翻转链表
- 原地翻转链表
- 链表的翻转
- 链表翻转
- 翻转部分链表
- 链表翻转
- 链表翻转
- c++翻转链表
- 翻转链表
- 链表翻转
- 翻转链表
- 链表翻转
- [LeetCode OJ] Reverse Words in a String 解题报告
- Codeforces Round #263 (Div. 2)
- 2个有序链表的合并
- 如何使用Uglify2.js分析函数中的依赖项
- Russian Dolls
- 链表翻转
- char 字符范围
- Aztec Pyramid
- jQuery+Ajax+PHP 制作简单的异步数据传输(测试用户名是否可用)
- window与linux共享 -samba
- Chemistry
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- 装寺疑凶底氯幕彻潘闻幕侗邓中宗
- java小题, 有100个人围成一个圈,从1开始报数,报到14的这个人就要退出。