摘要:
#include //非malloc#include typedef struct LNode{ int data; LNode* next; }LNode,*Linklist;void josephus(int n,int k,int m){ Linklist cur,head,prior,temp; head=(Linklist)malloc(sizeof(LNode)); head->data=1; head->next=head; cur=head;//当前节点设为头结点 for (int i=2; idata=i... 阅读全文
posted @ 2013-10-06 17:39
helo_blog
阅读(202)
评论(0)
推荐(0)
摘要:
//双栈实现队列//入栈:直接在栈A中入栈。//出栈:(1)如果栈B非空,栈B直接出栈;(2)如果栈B为空,将栈A中元素转移到栈B中,再由栈B出栈;#include using namespace std;templatestruct Myqueue{ stack s1; stack s2; void push(T &t) { s1.push(t); } void pop() { if(s2.empty()) { while(!s1.empty()) ... 阅读全文
posted @ 2013-10-06 11:19
helo_blog
阅读(191)
评论(0)
推荐(0)

浙公网安备 33010602011771号