摘要: 将单链表逆序单链表的逆置遍历一遍单链表,利用一个辅助指针存储遍历过程中当前指针指向下一个元素,然后将当前元素的指针反转,利用已经存储的指针往后继续遍历node *reverse(node *head){node *p,*q,*r;if(head->next==NULL)//链表为空{return head;}p=head->next;q=p->next;//保存原第二个节点p->next=NULL;//原第一个节点为末节点while(q!=NULL)//遍历各个节点的next指针反转{r=q->next;q->next=p;p=q;q=r;}head-> 阅读全文
posted @ 2014-05-08 21:26 ZhangAihua 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 单链表节点的删除删除单链表pos位置的节点,返回头指针pos从开始计算,1表示删除head后面的第一个节点node *delete_node(node *head,int pos){node *item=NULL;node *p=head->next;if(p==NULL){printf("link is empty\n");return NULL;}p=search_node(head,pos-1);//获得位置pos的节点指针if(p!=NULL && p->next!=NULL){item=p-... 阅读全文
posted @ 2014-05-08 21:13 ZhangAihua 阅读(717) 评论(0) 推荐(0) 编辑
摘要: 单链表节点的插入在单链表中某位置(pos个节点)后面插入节点1.插入到链表首部2.插入到链表中间3.插入到蓝标尾部单链表某个位置插入节点,返回链头指针,pos从0开始计算,0表示插入到head节点后面node *insert_node(node *head,int pos,int data){node *item=NULL;node *p;item=(node *)(sizeof(node));item->data=data;if(pos==0)//插入到链表头后面{head->next=item;return head;}p=search_node(he... 阅读全文
posted @ 2014-05-08 21:02 ZhangAihua 阅读(684) 评论(0) 推荐(0) 编辑
摘要: 单链表节点的查找查找单链表pos位置的节点,返回节点指针pos从0开始,0返回head节点node *search_node(node *head,int pos){node *p=head->next;if(posnext)==NULL){printf("incorrect position to search node\n");break;}}return p;} 阅读全文
posted @ 2014-05-08 20:53 ZhangAihua 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 计算单链表的长度计算单链表的长度,实现单链表的打印实现单链表的建立链表节点的定义:typedef struct node{int data;//节点内容node *next;//下一个节点}创建单链表node *Create(){int i=0;//链表中数据个数node *head,*p,*q;int x=0;head=(node*)malloc(sizeof(node));//创建头结点while(1){printf("input the data:");scanf("%d",&x);if(x==0)break;//Data为0时创建结束p= 阅读全文
posted @ 2014-05-08 20:39 ZhangAihua 阅读(2845) 评论(0) 推荐(0) 编辑
摘要: 实现单链表的建立链表节点的定义:typedef struct node{int data;//节点内容node *next;//下一个节点}创建单链表node *Create(){int i=0;//链表中数据个数node *head,*p,*q;int x=0;head=(node*)malloc(sizeof(node));//创建头结点while(1){printf("input the data:");scanf("%d",&x);if(x==0)break;//Data为0时创建结束p=(node*)malloc(sizeof(node 阅读全文
posted @ 2014-05-08 20:30 ZhangAihua 阅读(182) 评论(0) 推荐(0) 编辑
摘要: wxWidgets和Codeblocks的编译安装,GUI程序开发平台的搭建具体步骤如下:(1)基本编译环境安装安装编译工具(gcc之类)sudo apt-get install build-essential安装X11sudo apt-get install libx11-dev安装GTK需要的东西sudo apt-get install?gnome-core-devel(2)下载wxWidgets源码包并解压缩到 #{wxdir}(3)创建基于gtk和x11的编译目录${wx}mkdir ${wx}/buildgtkmkdir ${wx}/buildx11(4)编译wxgtkcd ${wx 阅读全文
posted @ 2014-05-08 09:45 ZhangAihua 阅读(274) 评论(0) 推荐(0) 编辑