会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
bluefly-hrbust
岂能尽如人意 但求无愧于心
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
10
11
12
13
14
15
16
17
18
···
23
下一页
2019年1月26日
POJ - 3264 线段树模板题 询问区间最大最小值
摘要: 这是线段树的一个模板题,给出一串数字,然后询问区间的最大最小值。 这个其实很好办,只需把线段树的节点给出两个权值,一个是区间的最小值,一个是区间的最大值,初始化为负无穷和正无穷,然后通过不断地输入节点,不断维护,最好每次询问维护一个询问区间的最大值和最小值,最后相减即可。其实就相当于,线段树找区间的
阅读全文
posted @ 2019-01-26 15:55 bluefly-hrbust
阅读(297)
评论(0)
推荐(0)
2019年1月16日
并查集模板
摘要: 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
阅读(220)
评论(0)
推荐(0)
2019年1月4日
链表逆至
摘要: 执行顺序 通过三个指针不断的移动,从而实现逆置。
阅读全文
posted @ 2019-01-04 19:58 bluefly-hrbust
阅读(272)
评论(0)
推荐(0)
2019年1月2日
循环链表版本-----约瑟夫环
摘要: 其实就是单链表的首位相连,不过需要注意的是链表需要注意这个头插法的尾节点应该插在第二个 然后需要注意的是,在删除的时候,我一般是用前后两节点进行扫描,然后前面那个一旦符合我要删除的条件,那么我就把后面那个指向前面那个的下一个。然后把前面的那个地址释放掉,然后用后一个指向的地址给前一个就实现了移动。
阅读全文
posted @ 2019-01-02 16:13 bluefly-hrbust
阅读(213)
评论(0)
推荐(0)
2018年12月28日
插入排序
摘要: #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
阅读(115)
评论(0)
推荐(0)
2018年12月27日
队列的模板
摘要: #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
阅读(329)
评论(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
阅读(299)
评论(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
阅读(165)
评论(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
阅读(782)
评论(0)
推荐(0)
2018年12月26日
希尔排序
摘要: #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
阅读(123)
评论(0)
推荐(0)
上一页
1
···
10
11
12
13
14
15
16
17
18
···
23
下一页
公告