- 博客(86)
- 收藏
- 关注
原创 SDUT2140图结构练习——判断给定图是否存在合法拓扑序列
#includeusing namespace std;int main(){ int v,e; while(~scanf("%d%d",&v,&e)) { bool map0[15][15]; int inde[15]; memset(map0,false,sizeof(map0)); memset(i
2016-08-02 15:59:33
307
原创 SDUT2506完美网络
#includeusing namespace std;int main(){ int n; scanf("%d",&n); while(n--) { int v,e,de[10050]; memset(de,0,sizeof(de)); priority_queue,greater > Q; s
2016-08-01 19:59:24
272
原创 SDUT2413n a^o7 !
#includeusing namespace std;char a[20]="n5!wpuea^o7! ";char b[20]="usimdnaevoli ";int main(){ char t[150]; for(int i=0; i<13; i++) t[a[i]]=b[i]; int T; scanf("%d\n",&T);
2016-08-01 15:53:20
301
原创 SDUT3363数据结构实验之图论七:驴友计划
#include#define MAX 2147483647using namespace std;struct ndoe{ int length,cost;} a[550][550];int v,e,v_start,v_end;void creat(){ for(int i=0; i<v; i++) for(int j=0; j<v; j++)
2016-08-01 14:44:36
524
原创 SDUT3362数据结构实验之图论六:村村通公路
#include#include#include#includeusing namespace std;struct node{ int u,v,w; bool operator < (const node &x)const { return w<x.w; }} q[1000002];int e=0;int fa[100002];
2016-08-01 09:44:28
1406
原创 SDUT3364数据结构实验之图论八:欧拉回路
#includeusing namespace std;int uf[1050];int de[1005];int find0(int x){ int r=x; while(uf[r]!=r) r=uf[r]; int i=x,j; while(i!=r) { j=uf[i]; uf[i]=r;
2016-08-01 08:47:14
361
原创 SDUT2129树结构练习——判断给定森林中有多少棵树
#includeusing namespace std;int uf[10050];int find0(int x){ int r=x; while(uf[r]!=r) r=uf[r]; //return r; int i=x,j; while(i!=r) { j=uf[i]; uf[i]=r;
2016-08-01 00:42:38
504
原创 SDUT2127树-堆结构练习——合并果子之哈夫曼树
#includeusing namespace std;int main(){ int n; scanf("%d",&n); priority_queue,greater > q; int cou[150],lhf=0; memset(cou,0,sizeof(cou)); while(n--) { int t;
2016-07-31 19:12:06
405
原创 SDUT3345数据结构实验之二叉树六:哈夫曼编码
#includeusing namespace std;int main(){ char a[50]; while(~scanf("%s",a)) { int asc2=8*strlen(a); priority_queue,greater > q; int cou[150],lhf=0; memset(
2016-07-31 18:34:34
705
原创 SDUT2482二叉排序树
#includeusing namespace std;char pre0[55],in0[55],post0[55];int pre00,in00,post00;struct tree{ char data; struct tree *lc,*rc;};void creat(struct tree *&node,char a){ if(node==NULL
2016-07-31 14:46:56
566
原创 SDUT3343数据结构实验之二叉树四:还原二叉树
#includeusing namespace std;struct tree{ char ch; struct tree *lc,*rc;};struct tree * creat(char *pre,char *in,int len){ if(len<=0) return NULL; struct tree *node; no
2016-07-31 13:06:09
599
原创 SDUT2128树结构练习——排序二叉树的中序遍历
#includeusing namespace std;struct tree{ int data; struct tree *lc,*rc;};int k;void sorttree(struct tree *&node,int a){ if(node==NULL) { node=(struct tree *)malloc(size
2016-07-31 11:04:44
298
原创 SDUT2137数据结构实验之求二叉树后序遍历和层次遍历
#includeusing namespace std;struct tree{ char ch; struct tree *lc,*rc;};struct tree * preincreat(char *pre,char *in,int len){ struct tree *node; if(len<=0) return NULL;
2016-07-30 20:35:53
462
原创 SDUT3398数据结构实验之排序一:一趟快排
#includeusing namespace std;void onceqsort(int a[],int left,int right){ int mid=a[left],i=left,j=right; if(left>=right) return; while(i<j) { while(i=mid)j--;
2016-07-30 15:03:03
430
原创 SDUT2139图结构练习——BFS——从起始点到目标点的最短步数
#includeusing namespace std;bool Map[1050][1050];struct node{ int x,s;};int bfs(int v){ bool vis[1050]; queue Q; memset(vis,false,sizeof(vis)); struct node t,k; t.x=v;
2016-07-30 09:25:47
249
原创 SDUT1028Catch That Cow
#includeusing namespace std;struct node{ int x,s;};int bfs(int n,int k){ queue Q; bool v[200200]; memset(v,false,sizeof(v)); int X,S; struct node t; t.x=n; t.s=0
2016-07-29 20:52:05
211
原创 SDUT3361数据结构实验之图论四:迷宫探索
#includeusing namespace std;bool Map[120][120];bool vis[120];int a[120],top=0;void dfs(int s,int v){ a[top++]=s; vis[s]=true; for(int i=1; i<=v; i++) if(Map[s][i]&&!vis[i])
2016-07-29 15:04:04
378
原创 SDUT2107图的深度遍历
#includeusing namespace std;bool Map[120][120];bool vis[120];void dfs(int s,int v){ for(int i=0; i<v; i++) if(Map[s][i]&&!vis[i]) { vis[i]=1; printf("
2016-07-29 13:33:27
469
原创 SDUT3347数据结构实验之数组三:快速转置
#includeusing namespace std;struct node{ int x,y,k;};bool operator < (struct node x0,struct node y0){ if(x0.x==y0.x)return x0.y<y0.y; else return x0.x<y0.x;}int main(){ int mu
2016-07-29 09:06:20
559
原创 SDUT1442面向对象程序设计上机练习三(有默认参数的函数)
#includeusing namespace std;int main(){ int a,b,c; cin>>a>>b>>c; cout<<a<<" "<<b<<" "<<max(a,b)<<endl; cout<<a<<" "<<b<<" "<<c<<" "<<max(max(a,b),c)<<endl;}
2016-07-28 13:48:50
280
原创 SDUT1141面向对象程序设计上机练习二(函数模板)
#includeusing namespace std;template void maxf(T a[]){ T maxx=0; for(int i=0; i<5; i++) if(a[i]>maxx) maxx=a[i]; cout<<maxx<<endl;}int main(){ int a[8];
2016-07-28 13:42:19
567
原创 SDUT1140面向对象程序设计上机练习一(函数重载)
#includeusing namespace std;void maxf(int a[]){ int maxx=0; for(int i=0; i<5; i++) if(a[i]>maxx) maxx=a[i]; cout<<maxx<<endl;}void maxf(float a[]){ float maxx
2016-07-28 13:18:36
609
原创 SDUT2132数据结构实验之栈二:一般算术表达式转换成后缀式
#includeusing namespace std;void transf(char mid[],char suf[],char stack0[]){ int is=0,im; stacks; for(im=0;mid[im]!='#';im++) { if(mid[im]>='a'&&mid[im]<='z') {
2016-07-27 13:35:32
347
原创 SDUT3333&&SDUT3332数据结构实验之栈五:下一较大值(一)
#includeusing namespace std;struct node{ int num,next,id;};void nextmax(int n){ stacks; struct node a[100050],t; for(int i=1; i<=n; i++) { scanf("%d",&a[i].num);
2016-07-27 09:28:09
667
原创 SDUT顺序表系列
#includeusing namespace std;bool hash[20050];int hashs[20050];struct node{ int *h,lt,ls;};void intl(struct node *l){ l->h=(int *)malloc(10050*sizeof(int)); l->lt=0;
2016-07-26 20:38:07
458
原创 SDUT1334简单字符串排序
#includeusing namespace std;struct node{ char name[25]; int score;} a[15];bool operator <(struct node x,struct node y){ if(strcmp(x.name,y.name)<0)return 1; else return 0;}int
2016-07-25 23:54:41
536
原创 SDUT2449走迷宫
#includeusing namespace std;int road,n,m,a[10][10],vis[10][10];void dfs(int x,int y){ if(xn-1||ym-1||vis[x][y]||a[x][y]) return; else if(x==n-1&&y==m-1) { road++;
2016-07-25 23:53:53
607
原创 SDUT1479数据结构实验之栈:行编辑器
#includeusing namespace std;char a[300];char stac[310];int main(){ while(gets(a)!=NULL) { int ans=0; int i,l=strlen(a); for(i=0; i<l; i++) { i
2016-07-25 23:52:59
289
原创 SDUT1130数据结构上机测试1:顺序表的应用
#includeusing namespace std;int main(){ int n,a[1050],hash[1050],k=0; scanf("%d",&n); for(int i=0; i<n; i++) { scanf("%d",&a[i]); hash[a[i]]=1; } for(int i=0
2016-07-25 23:13:55
379
原创 SDUT2134数据结构实验之栈四:括号匹配
#includeusing namespace std;void f(char a[]){ char stack[100]; int k=0,f=1; for(int i=0; a[i]!='\0'; i++) { if(a[i]=='('||a[i]=='['||a[i]=='{') stack[++k]=a[i];
2016-07-25 13:28:01
356
原创 SDUT2131数据结构实验之栈一:进制转换
#includeusing namespace std;void f(int n,int r){ stacks; while(n) { int t=n%r; s.push(t); n/=r; } while(!s.empty()) { printf("%d",s.top());
2016-07-25 13:26:32
472
原创 SDUT1252进制转换
#includeusing namespace std;void f(int n,int r){ stacks; while(n) { int t=n%r; if(t<10)t+=48; else t+=55; s.push(t); n/=r; } while(!s.emp
2016-07-25 13:25:46
347
原创 SDUT2121数据结构实验之链表六:有序链表的建立
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*p,*q;void insertsort(int n){ struct node *x,*y; while(n--) { q=(struct node *)malloc(size
2016-07-23 11:20:45
528
原创 SDUT2119数据结构实验之链表四:有序链表的归并
#includeusing namespace std;struct node{ int data; struct node *next;}*head1,*head2,*tail,*p,*q;int n1,n2;struct node * built(int n){ struct node *head; head=(struct
2016-07-23 09:18:13
663
原创 SDUT2118数据结构实验之链表三:链表的逆置
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*p,*q;int n,t;void built(){ head=(struct node *)malloc(sizeof(struct node)); tail=he
2016-07-22 20:50:27
375
原创 SDUT2117数据结构实验之链表二:逆序建立链表
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*p;int n;void built(){ head=(struct node *)malloc(sizeof(struct node)); head->next=NULL; wh
2016-07-22 08:52:54
317
原创 SDUT2116数据结构实验之链表一:顺序建立链表
#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*p;int n;void built(){ head=(struct node *)malloc(sizeof(struct node)); tail=head; while(n-
2016-07-22 08:49:36
343
原创 SDUT1138数据结构上机测试2-1:单链表操作A
此题坑点在对末尾节点的操作,避免指针越界#includeusing namespace std;struct node{ int data; struct node *next;}*head,*tail,*q,*p;int n,key;void built(){ head=(struct node *)malloc(sizeof(struct node))
2016-07-21 18:35:39
302
原创 SDUT1130数据结构上机测试1:顺序表的应用(上一个代码太蠢)
#includeusing namespace std;int a[1050],hash[1050];int main(){ int n,k=0; scanf("%d",&n); for(int i=0; i<n; i++) scanf("%d",&a[i]); memset(hash,0,sizeof(hash)); for(int
2016-07-21 17:23:50
387
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅