- 浏览: 438083 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (538)
- C/C++ Primer (69)
- Objective-C Primer (102)
- Python Primer (19)
- JavaScript Primer (1)
- Java Primer (37)
- PHP Primer (17)
- 泛 Linux (37)
- Shell Script (21)
- APUE (21)
- UNP__1&2 (19)
- NetWork (7)
- Oracle周边 (38)
- Mysql里边 (6)
- Windows技 (9)
- 简单算法 & 数据结构 (14)
- 设计模式 (6)
- GTK历程 (12)
- 工具使用 (25)
- 杂事 (23)
- 一些概念 (17)
- Web方面 (10)
- myCodeTools (9)
- ^未 竟$ (13)
- 硬件通信 (2)
- Games (1)
最新评论
双向循环链表
struct node { int id; int data; int status; struct node *up; struct node *next; }; class DoubleLink { public: DoubleLink(); ~DoubleLink(); node* up(); node* next(); node* getCurrent(); int getSize(); node* addNode(int size); void deleteNode(int size); // 删除size个节点 void deleteLink(); // 删除整条 void show(); void showDesc(); private: node* current; void creatLink(); };
DoubleLink::DoubleLink() { creatLink(); } DoubleLink::~DoubleLink() { if (current != NULL) deleteLink(); } void DoubleLink::creatLink() { current = (node *)malloc(sizeof(node)); current->up = current; current->next = current; current->id = 0; current->data = 0; current->status = 0; } void DoubleLink::deleteLink() { current->up->next = NULL; while (current != NULL) { node *p = current->next; free(current); current = p; } current = NULL; } void DoubleLink::deleteNode(int size) { if (getSize() <= size) deleteLink(); node *beg = current->up; for (int i = 0; i < size; i++) { node *p = current->next; free(current); current = p; } current->up = beg; beg->next = current; } node* DoubleLink::addNode(int size) { node *beg = current; node *end = current->next; for (int i = 0; i < size; i++) { node *mid = (node *)malloc(sizeof(node)); beg->next = mid; mid->up = beg; beg = mid; } beg->next = end; end->up = beg; return current; } int DoubleLink::getSize() { int size = 1; node *p = current->next; while (p != current) { p = p->next; size++; } return size; } void DoubleLink::show() { cout << "DoubleLink Show :" << endl; cout << "第0个: " << current->data << endl; node *p = current; p = p->next; for (int i = 1; p != current; i++) { cout << "第"<< i << "个: " << p->data << endl; p = p->next; } } void DoubleLink::showDesc() { cout << "DoubleLink Show Desc :" << endl; cout << "第0个: " << current->data << endl; node *p = current; p = p->up; for (int i = 1; p != current; i++) { cout << "第"<< i << "个: " << p->data << endl; p = p->up; } } node* DoubleLink::up() { return current->up; } node* DoubleLink::getCurrent() { return current; } node* DoubleLink::next() { return current->next; }
发表评论
-
A星寻路+堆排序
2012-03-27 22:24 676http://www.vckbase.com/document ... -
线性运动
2012-02-07 14:03 734线性运动:y=ax+z ==> P=(x0+ax ... -
SQ题
2011-11-17 11:16 6251.烧一根不均匀的绳,从头烧到尾总共需要1个小时。现在有 ... -
钦天监
2011-10-28 15:42 672http://www.360doc.com/content/0 ... -
排序....
2011-08-25 14:17 660http://zh.wikipedia.org/wiki/%E ... -
给far的单链表代码
2011-03-30 22:31 441纯纪念 #include <stdio.h> # ... -
贪心取最大和
2011-03-28 12:03 735贪婪算法: 1、不追求最优解,故不穷举所有可能性,故效率高; ... -
单链表倒数N个的地址
2011-03-08 08:52 792又给人问倒了~ 单链表的长度L,那么倒数N个的位置:L - ... -
折半查找
2011-03-08 08:51 762最近被人问题,事隔三年了,貌似没什么进步,又写了一遍。 ... -
Hash哈希表
2010-12-16 22:36 661比较方法: 一、直接原数据的比较 二、数据通过某种映射后比较 ... -
Hannoi
2010-11-03 11:38 664每次看问题的层次,偶尔有不同的想法,看来层次提高了 # ... -
KMP字符串匹配
2010-09-26 15:49 531http://lemonmilk.blog.51cto.com ... -
深度优先 - 路径的选择
2010-09-21 10:22 795class PathInfo //数据存储 ...
相关推荐
(整数,正负均可),一开始任选一个正整数作为报数上限值m,从第一个人开 ... ...则逆时针)上的下一个人开始重新从1报数,如此下去,直至所有人全部出列。...用c中的数组和链表方法可以求出出列的顺序。
分别用数组和链表解决约瑟夫环问题。 数组和链表.doc
纯手写 java 数组模拟链表约瑟夫环问题 有很大更改空间 仅供参考
分别用数组和链表实现约瑟夫环,经调试正确无误
这是用数组表示循环链表,解决约瑟夫环的问题。匹配的报告实验报告随后上传。
约瑟夫环问题的链表和数组两种解法 设有N个人围坐一圈并按顺时针方向从1到N编号,从第S个人开始进行1到M报数,报到第M个人时,此人出圈,再从他的下一个人重新开始1到M的报数,如此进行下去直到所有的人都出圈为止,...
分别用数组和链表实现的约瑟夫环问题,内有详细的介绍。
数组实现约瑟夫环 数组实现约瑟夫环 数组实现约瑟夫环 数组实现约瑟夫环 数组实现约瑟夫环
这是数组表示循环链表的约瑟夫环的实验报告。与上面的源代码相匹配。
cpp文件内采用两种方式实现经典的约瑟夫出圈问题,分别以数组方式和链表方式实现。同时,也可以实现直接输出最后的获胜者。
用c语言分别用一位数组 结构体 循环链表等方式编写约瑟夫环的代码!
使用一维数组、一维结构体数组、循环链表三种方法完成;
用C++做的单循环链表简单表示了约瑟夫问题
约瑟夫问题有多种解决方案 一种是数组方案 一种是链表方案 这种事数组,链表方案与数组方案哪个更优 需要读者去考虑
此资源属于算法分析课程的实验(本程序的两种实现方法都使用了相同的界面来输出,所以单看界面是看不出其中的不同之处的,不同之处体现在dao包里面的源文件里)只供学习使用。本人很少上CSDN,有兴趣,有需要的话...
分别用一维数组,结构体数组,循环链表实现约瑟夫环问题,功能完备,代码添加注释,经典易懂
分别用 C++类实现 C链表实现 C数组实现 如有不清楚的地方欢迎 加QQ309669771 一起学习
多种方法解决约瑟夫环问题,1.顺序表2.循环链表3.循环队列4.普通一位数组
约瑟夫环的三种风格做法 1.普通指针的运用 2.数组+可视化模拟器 3.双向链表
该程序用c++编写。约瑟夫问题可以用指针链表实现也可以用数组实现。这里提供一个用数组实现的,链表的可参考该算法实现