ITfeng

 

2012年4月22日

链表的操作-三种插入法,删除,打印

摘要: //链表有序插入和删除最重要的是预判,就是判断下一个是否满足要求,因为如果只是判断当前,那么当你找到要操作的节点时,已经过了指向该节点的指针//删除的时候注意释放空间#include<stdio.h>#include<stdlib.h>typedef struct list{int data;struct list*next;}List;void insert_list_2nd(List*head,int data);//表头插入 void insert_list_last(List*head,int data);//表尾插入 void insert_list_orde 阅读全文

posted @ 2012-04-22 22:15 ITfeng 阅读(264) 评论(0) 推荐(0) 编辑

用循环数组实现队列

摘要: //以让数组得到充分的利用,所以采用循环数组//队列为空,则front==rear 如果队列满了,(rear+1)%N=front 数组中最后一个元素未利用 是为了区分空和满的情况 #include<stdio.h>#include<stdlib.h>#define N 100typedef struct queue{int store[N];int front;int rear;}Queue;void init_queue(Queue*q) {q->front=q->rear=0;}void inqueue(Queue*q,int data){if((q- 阅读全文

posted @ 2012-04-22 21:14 ITfeng 阅读(4296) 评论(0) 推荐(0) 编辑

导航