- 博客(43)
- 资源 (6)
- 收藏
- 关注
原创 找女朋友
#include int a[1000005] ; int part (int *p ,int b ,int e) { int key ; key = p[b] ; while(b < e) { while (b = key) { e -- ;
2016-08-23 09:30:50 292 1
原创 一趟快排
#include#includeint num[10005];int quicksort(int l,int r){ int i,j,k; if(l>r) return 0; k=num[l]; i=l; j=r; while(i<j) { while(num[j]>=k&&i<j) {
2016-08-23 09:30:18 479
原创 选课名单
#includeusing namespace std;struct no{ char name[15];}a[35005][2005];char st[15];int cou[2500];int cmp(no a,no b){ return strcmp(a.name,b.name)<0;}int main(){ int n,m,i,j,k,t;
2016-08-23 09:29:42 358
原创 线性哈希
#includeint a[1010];int main(){ int n,p,i,m,j,k; while(~scanf("%d %d",&n,&p)) { memset(a,-1,sizeof(a)); for(i=1;i<=n;i++) { scanf("%d",&m);
2016-08-23 09:28:20 331
原创 查找练习 hash——出现过的数字
#includeint a[101000];int main(){ int n,p,i,m,k; scanf("%d %d",&n,&p); memset(a,-1,sizeof(a)); for(i=1;i { scanf("%d",&m); if(a[m]==-1) {
2016-08-23 09:21:06 235
原创 平方哈希表
开放定址法处理冲突其中,H(key)为哈希函数 m为哈希表长 di为增量序列可有下列3种取法:(1). ,称为线性探测再散列;(2). 称二次探测再散列。(3). di = 伪随机数序列,称伪随机探测再散列。#includeint a[505];int main(){ int n,p,i,j,m,k;
2016-08-22 20:29:28 308
原创 希尔排序
#includeint a[10005];int n;void shell(int d){ int i,j,t; for(i=d;i<n;i++) { t=a[i]; for(j=i;j>=d&&a[j-d]>t;j-=d)//减到0为止 { a[j]=a[j-d]; }
2016-08-22 17:26:03 194
原创 数据结构实验之排序四:寻找大富翁
用数组来建立树的模型,每次要从m/2开始;#includeint a[11];void dun(int s,int m){ int l=s; int ll=2*s; int lr=2*s+1; int h; if(s<=m/2) { if(lla[ll]) { l=ll; }
2016-08-22 14:56:44 249
原创 数据结构实验之排序五:归并求逆序数
#include#includeint a[100001],t[100001];long long num;void sort(int b1,int e1,int b2,int e2){ int p=0,p1=b1,p2=b2; while(p1 { if(a[p1] { t[p++]=
2016-08-22 14:46:23 309
原创 n a^o7 !
#includechar a[]="n5!wpe^o7au";char b[]="usimdavolen";int main(){ int t; char s[101]; scanf("%d\n",&t); for(int k=1;k<=t;k++) {gets(s); int l=strlen(s); for
2016-08-19 15:58:57 452
原创 数据结构实验之图论六:村村通公路
#include#define inf 0x3f3f3f3fint road[1005][1005];int visit[1005];int cost[1005];int n,m,total;int prime(){ int i,j,k,t,f; visit[1]=1; for(i=1;i<=n;i++) { cost[i]=road[i][1]; } f
2016-08-19 15:57:52 563
原创 图结构练习——BFS——从起始点到目标点的最短步数
#includeusing namespace std;typedef struct no{ int data; int step;} node;int num[2000][2000],visit[10010];int bfs(int b,int k){ node t,f; int i; queue q; t.data=b;
2016-08-19 15:57:03 219
原创 最小生成树
#includeusing namespace std;int fi[105],num;typedef struct no{ int u,v,q;}node;node a[10005];int cmp(node d,node b){ return d.q<b.q;}int find(int n){ while(n!=fi[n]) {
2016-08-19 15:53:52 203
原创 图结构练习——最短路径
#include#define inf 0x3f3f3f3fint a[101][101];int main(){ int n,m,i,j,k,u,v,q; while(~scanf("%d %d",&n,&m)) { memset(a,0,sizeof(a)); for(j=0; j<=n; j++) {
2016-08-19 15:52:55 234
转载 AOE网上的关键路径 (SPFA+前向星)
AOE网上的关键路径Time Limit: 1000MS Memory limit: 65536K题目描述 一个无环的有向图称为无环图(Directed Acyclic Graph),简称DAG图。 AOE(Activity On Edge)网:顾名思义,用边表示活动的网,当然它也是DAG。与AOV不同,活动都表示在了边上,如下图所示:
2016-08-19 11:22:02 413
原创 欧拉回路
记得用DFS或者BFS或者并查集判断一下顶点个数。#includeusing namespace std;int inde[1100],visit[1001],n,m,num;int a[1100][1100];void DFS(int l){ int i; visit[l]=1; num++; for(i=1;i<=n;i++) {
2016-08-18 20:07:11 132
原创 拓扑排序
#includeusing namespace std;int inde[50],n,m;int a[50][50];void tuo(){ queue q; int i,total=0; for(i=1;i { if(inde[i]==0) { q.push(i);
2016-08-18 19:32:42 157
原创 数据结构实验之图论七:驴友计划
#include#define inf 0x3f3f3f3ftypedef struct no{ int l; int c;}node;node a[501][501];int visit[501];node dis[501];int n,m,s,d;void dijks(){ visit[s]=1; int min,i,j,k,u; f
2016-08-18 16:09:52 259
原创 Catch That Cow
#include#include#includeusing namespace std;int visit[105000];struct node{ int p,s;} ;int k;bool cmp(int d){ if(d=100001||visit[d])//注意边界,不然会RE啊 return false; return tru
2016-08-17 19:02:29 145
原创 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
#includeusing namespace std;typedef struct no{ int num; struct no *next;}node; node *head[105]; int visit[10000]; void creat(int u,int v) { node *p; p=new
2016-08-15 21:23:03 189
原创 数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历
#includeusing namespace std;int num[2000][2000],visit[10000];int bfs(int b,int k){ int i; queue q; q.push(b); visit[b]=1; int flag=1; while(!q.empty()) { int h=
2016-08-15 20:54:03 193
原创 数据结构实验之排序七:选课名单
建立二维数组,利用下标来解决。#includeusing namespace std;struct no{ char name[15];}a[35005][2005];char st[15];int cou[2500];int cmp(no a,no b){ return strcmp(a.name,b.name)<0;}int main(){ int
2016-08-15 16:42:37 230
原创 一趟快排
#include#includeint num[10005];int quicksort(int l,int r){ int i,j,k; if(l>r) return 0; k=num[l]; i=l; j=r; while(i<j) { while(num[j]>=k&&i<j) {
2016-08-15 11:30:27 236
原创 SDUT完美网络
用优先队列做,凡是小于2的度进入队列。第一组数据有点问题。#include#include#include#includeusing namespace std;int net[10005];int main(){ int t,i,n,m,x,y,a,b,num,k; priority_queue,greater > q; scanf("%d",&t);
2016-08-15 10:57:31 396 1
原创 平衡二叉树
#include #include #include using namespace std;typedef struct bitnode{ int data; int d; struct bitnode *lchild, *rchild;}* bitree;int deep(bitree &t){ if(!t) return -1
2016-08-13 16:57:11 192
原创 二分查找
#includeusing namespace std;int num[1000005];int erfen(int l,int r,int key){ int mid=l+(r-l)/2; if(l<=r) { if(num[mid]==key) { return mid; } else {
2016-08-13 14:44:35 197
原创 树-堆结构练习——合并果子之哈夫曼树
#includeusing namespace std;int bb[1000];priority_queue,greater > q;int main(){ int n,i,lc,m; scanf("%d",&n); memset(bb,0,sizeof(bb)); for(i=0; i<n; i++) { scanf("%d",
2016-08-12 19:19:34 402
原创 数据结构实验之二叉树六:哈夫曼编码
#includeusing namespace std;string st;int bb[1000];priority_queue,greater > q;int main(){ int i,la,lc; while(cin>>st) { la=8*st.size(); memset(bb,0,sizeof(
2016-08-12 16:03:17 235
原创 数据结构实验之查找三:树的种类统计
#includeusing namespace std;typedef struct no{ char data[25]; int num; struct no *lc,*rc;}node;int n;node *creat(char *n){ node *p; p=new node; p->num=1; strcpy(p->d
2016-08-11 19:41:41 320
原创 数据结构实验之查找一:二叉排序树
#includeusing namespace std;typedef struct no{ int data; struct no *lc,*rc;}node;node *creat(int n){ node *p; p=new node; p->data=n; p->lc=NULL; p->rc=NULL; retur
2016-08-11 16:40:14 441
原创 求二叉树的深度
#include#includeusing namespace std;typedef struct no{ char data; struct no *lc,*rc;} node;char a[50],b[50];node *creat(char *x,char *z,int k){ node *p; p=new node; if(k==0
2016-08-09 20:25:32 205
原创 数据结构实验之求二叉树后序遍历和层次遍历
#include#include#include#includeusing namespace std;typedef struct no{ char data; struct no *lc,*rc;} node;int i=0;char a[500],b[500];node *creat(char *a,char *b,int k){ int m;
2016-08-09 11:10:39 230
原创 数据结构实验之二叉树的建立与遍历
#include#includetypedef struct no{ char data; struct no *lc,*rc;}node;int l=0,k=0;char a[50];node *creat(){ node *p; char c; c=a[l++]; if(c==',') { return N
2016-08-08 19:27:17 209
原创 数据结构实验之链表七:单链表中重复元素的删除
#include#include#includetypedef struct no{ int data; struct no *next;} node;node *creat(int k){ int i,m; node *p,*head; head=(node *)malloc(sizeof(node)); head->next=NUL
2016-08-06 10:34:18 442
原创 数据结构实验之串一:KMP简单应用
#include#include#includechar a[1000001],b[1000001];int next[1000001];void getnext(){ int i=0,j=-1; int l=strlen(b); next[0]=-1; while(i<l) { if(j==-1||b[i]==b[j])
2016-08-05 15:14:50 203
原创 数据结构实验之数组二:稀疏矩阵
#includestruct no{ int h,l,z;};struct no s[1001];int main(){ int i,j,k,l,g; while(~scanf("%d %d %d",&j,&k,&l)) { for(i=1;i<=l;i++) { scanf("%d %d %d",&s[i].h,
2016-08-05 15:06:11 577
原创 数据结构实验之串三:KMP应用
#include#includeint a[10000100],b[10000100];int next[10000100];int n,k,m;void getnext(){ int l,i,j; l=m; i=0;j=-1; next[0]=-1; while(i { if(j==-1||b[
2016-08-05 11:20:37 272
原创 串连接
#include#include#includetypedef struct{ char *ch; int length;}str;int i,j;char a[200],b[200];void strassign(str &t,char *s){ char *c; if(t.ch) { t.ch=NUL
2016-08-03 19:22:08 1725
原创 串匹配
#include#include#includeusing namespace std;char a[110],b[110];int main(){ while(~scanf("%s",a)) { scanf("%s",b); if(strstr(a,b)) printf("YES\n");
2016-08-03 19:21:11 264
原创 停车场(队列)
#include#include#include#include#include#include#includeusing namespace std;int main(){ char c[10],d[20]; int n,m,i,k,num; while(~scanf("%d%d",&n,&m)) {
2016-08-02 17:29:09 732
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人