摘要:
队列是常见的数据结构,特点是:从头删除,从尾加入。本文使用双向链表实现队列,具体代码如下: 1 #include<stdlib.h> #inlcude<stdio.h> 2 #define new(type) (type*)malloc(sizeof(type)) 3 typedef struct ListNode{ 4 int data; 5 struct ListNode *lLink; 6 struct ListNode *rLink; 7 }Queue; 8 Queue* Insert(Queue *tail,int x){ 9 Queue* ptr... 阅读全文
posted @ 2013-04-29 19:09
Licious
阅读(517)
评论(0)
推荐(0)
摘要:
问题介绍:M个人围成一圈,从第一个开始报数,第N个将被杀掉,最后剩下一个,其余人都将被杀掉。例如M=6,N=5,被杀掉的人的序号为5,4,6,2,3。最后剩下1号。这里使用循环链表数据结构实现,代码如下: 1 #include<stdlib.h> #include<stdio.h> 2 #define new(type) (type*)malloc(sizeof(type)) 3 typedef struct _LinkNode{ 4 int number; 5 struct _LinkNode *next; 6 }LinkNode; 7 Josephus(LinkNo 阅读全文
posted @ 2013-04-29 19:05
Licious
阅读(227)
评论(0)
推荐(0)
浙公网安备 33010602011771号