上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页
摘要: 这是线段树的一个模板题,给出一串数字,然后询问区间的最大最小值。 这个其实很好办,只需把线段树的节点给出两个权值,一个是区间的最小值,一个是区间的最大值,初始化为负无穷和正无穷,然后通过不断地输入节点,不断维护,最好每次询问维护一个询问区间的最大值和最小值,最后相减即可。其实就相当于,线段树找区间的 阅读全文
posted @ 2019-01-26 15:55 bluefly-hrbust 阅读(283) 评论(0) 推荐(0) 编辑
摘要: void init(){for(int i=1;i<=maxx;i++)pre[i]=i;}//初始化 //注意如果序列内节点编号是大于n的,要初始化到最大,建议最开始初始化到最大 int Find(int x){return pre[x]==x?x:(pre[x]=Find(pre[x]));}//状态压缩+找最上面的祖先 void join(int x,int y){fx=Find(x);... 阅读全文
posted @ 2019-01-16 23:50 bluefly-hrbust 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 执行顺序 通过三个指针不断的移动,从而实现逆置。 阅读全文
posted @ 2019-01-04 19:58 bluefly-hrbust 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 其实就是单链表的首位相连,不过需要注意的是链表需要注意这个头插法的尾节点应该插在第二个 然后需要注意的是,在删除的时候,我一般是用前后两节点进行扫描,然后前面那个一旦符合我要删除的条件,那么我就把后面那个指向前面那个的下一个。然后把前面的那个地址释放掉,然后用后一个指向的地址给前一个就实现了移动。 阅读全文
posted @ 2019-01-02 16:13 bluefly-hrbust 阅读(206) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; struct sqlist{ int *elem; int length; }; void creat(sqlist &a){ a.elem=(int *)malloc(sizeof(int)); int n,tmp; scanf("%d",&n); for ... 阅读全文
posted @ 2018-12-28 12:23 bluefly-hrbust 阅读(109) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; typedef struct Qnode{ int data; Qnode *next; }Qnode,*QueuePtr; typedef struct{ QueuePtr fronts; QueuePtr rear; }LinkQueue; void cre... 阅读全文
posted @ 2018-12-27 23:34 bluefly-hrbust 阅读(324) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; typedef struct sqstack{ int *base; int *top; int sizestack; }sqstack; void creat_stack(sqstack &a){ a.base=(int*)malloc(100*sizeof(... 阅读全文
posted @ 2018-12-27 22:41 bluefly-hrbust 阅读(292) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; typedef struct sqstack{ char *base; char *top; int stacksize; }sqstack; void creat_stack(sqstack &a){ a.base=(char *)malloc(100*sizeo... 阅读全文
posted @ 2018-12-27 22:07 bluefly-hrbust 阅读(161) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; typedef struct Lnode { int data; Lnode *next; } Lnode,*linklist; void creat_back(linklist &a) { int n,tmp; linklist p,q; a... 阅读全文
posted @ 2018-12-27 21:24 bluefly-hrbust 阅读(774) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; void shellsort(int a[],int n){ int i,j; int jump=n; do{ jump=jump/3+1;//浮动 for (i=jump+1;i0 && a[0]1); } int main(){ int a[100]; int n; ... 阅读全文
posted @ 2018-12-26 23:56 bluefly-hrbust 阅读(113) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页