摘要:
//链表首尾节点的常规方案 //示例代码片段,不能编译 /////////////////////////////////////////////////////////////// //循环,永远非空 head->next = head; //头插入 t->next = x->next; x->next = t; //x节点后插入t节点 x->next = x->next->next; //删除x后的节点 t=head; do{ t=t->next; } while(t != head) //循环遍历... 阅读全文
posted @ 2012-10-18 22:29
wouldguan
阅读(848)
评论(0)
推荐(0)
摘要:
/* 链表插入排序例子 Wirtten by: nick Date: 2012-10-18 19:56*/#include <iostream>#include <iomanip>#include <cstdlib>using namespace std;struct node{ int item; node *next; node(int x, node* t) { item = x; next = t; }};typedef node *link;link reverse(link x){ link t, y... 阅读全文
posted @ 2012-10-18 21:53
wouldguan
阅读(3622)
评论(0)
推荐(0)
摘要:
/* 链表逆转操作 Wirtten by: nick Date: 2012-10-18 19:56*/#include <iostream>#include <iomanip>using namespace std;struct node{ int item; node *next; node(int x, node* t) { item = x; next = t; }};typedef node *link;link reverse(link x){ link t, y=x, r=0; while(y!... 阅读全文
posted @ 2012-10-18 21:25
wouldguan
阅读(601)
评论(0)
推荐(0)
摘要:
/* Josephus问题 -- n个人围成一圈,按顺序数数,每次第m个人出局,求最后一个 Wirtten by: nick Date: 2012-10-18 19:56*/#include <iostream>#include <iomanip>using namespace std;struct node{ int item; node *next; node(int x, node* t) { item = x; next = t; }};typedef node *link;int main(){ int... 阅读全文
posted @ 2012-10-18 21:03
wouldguan
阅读(964)
评论(0)
推荐(0)
摘要:
/* 1000以内的质数 Wirtten by: nick Date: 2012-10-18 19:56*/#include <iostream>#include <iomanip>using namespace std;typedef int Integer;static const int MAX_N = 1000;int main(){ int arr[MAX_N]; for(int i=2; i<MAX_N; i++) arr[i] = 1; for(int i=2; i<MAX_N; i++) if(arr[i]) ... 阅读全文
posted @ 2012-10-18 19:57
wouldguan
阅读(1222)
评论(0)
推荐(0)
浙公网安备 33010602011771号