未经验证的堆 C 代码,求验证
来源:互联网 发布:md5加解密网站源码php 编辑:程序博客网 时间:2024/06/05 05:14
rt
#include <stdio.h>#include <stdlib.h>int len;int heap[20];void swap(int *a,int *b){ int tmp=*a; *a=*b; *b=tmp;}void push_heap(int *heap,int s){ heap[++len]=s; int t=len; while (t>1) { if (heap[t>>1]>heap[t]) { swap(&heap[t>>1],&heap[t]); } else return; }}int pop_heap(int *heap){ int re=heap[1],x; heap[1]=heap[len--]; int m=len>>1,t=1,k; while (t<=m) { k=t; if (heap[t<<1]<heap[t]) k=t<<1; if ((t<<1)+1<=len) if(heap[k]>heap[(t<<1)+1]) k=(t<<1)+1; if (k!=t) { x=heap[k]; heap[k]=heap[t]; heap[t]=x; t=k; } else return re; } return re;}void heap_adjust(int *heap,int pos,int end){ int i; int t=heap[pos]; for (i=2*pos;i<=end;i<<=1) { if (i<end && heap[i]<heap[i+1]) ++i; if (heap[pos]>heap[i]) break; heap[pos]=heap[i]; pos=i; } heap[pos]=t;}void sort_heap(int *heap){ int i; int t; for (i=len/2;i>0;i--) heap_adjust(heap,i,len); for (i=len;i>1;i--) { swap(&heap[1],&heap[i]); heap_adjust(heap,1,i-1); }}int main(){ scanf("%d",&len); int i; for (i=1;i<=len;++i) scanf("%d",&heap[i]); sort_heap(heap); push_heap(heap,9); while (len>0) printf("%d\n",pop_heap(heap)); system("pause");}
- 未经验证的堆 C 代码,求验证
- JS验证代码大全(部分未经过验证,自行验证)
- django 实现未经登录验证的url过滤
- 未经过验证的在scrapy中获取cookies
- 渗透测试之未经验证的重定向漏洞
- [求下面函数的返回值]代码验证
- VS工具箱缺失项(未经验证)
- 验证登录的代码
- 验证代码的生成
- html5的代码验证
- JAVA的验证代码
- 求用c语言验证哥德巴赫猜想
- Firefox Developer Edition已阻止此网站安装未经验证的附加组件的解决办法
- asp.net(C#) 生成随机验证码的代码
- asp.net(C#)图片随机验证码的代码!
- C#中常用到的密码修改及正则验证代码
- jsp存取mysql中文数据结果为乱码的解决方法(未经验证)
- 在jsp页面使用session来验证未经登录的访问 并完成直接跳转
- android测试一些心得
- C++程序设计语言--第十五章:类层次结构
- Flex 专栏 -- Flex 中有两种弹出窗口
- 网站性能最佳惯例和规则
- linux-2.6.35内核移植—Nand flash驱动的添加(分区)
- 未经验证的堆 C 代码,求验证
- linux-2.6.35内核移植—LCD驱动的添加
- 在一个Android application 调用另一个 application 里的 Activity 和 Service
- linux-2.6.35内核移植—USB驱动的添加
- Hadoop掀起大数据革命 三巨头齐发力
- 变长参数(忘了转载地址了)
- linux-2.6.35内核移植—SD卡驱动的添加
- 常用shell命令
- Android上面开发自己的Toast系统的思路