2012年12月19日

POJ2255

摘要: #include<iostream>#include<cstdio>#include<string.h>using namespace std;void postorder(char *prestart,char *preend,char *instart,char *inend){ char root=*prestart; int len=preend-prestart; int i; for(i=0;*(instart+i)!=root&&i<=len;i++); if(i!=0)postorder(prestart+1,prest 阅读全文

posted @ 2012-12-19 13:39 dokc 阅读(145) 评论(0) 推荐(0) 编辑

poj3094

摘要: #include<stdio.h>#include<string.h>#include<iostream>using namespace std;char s[]=" ABCDEFGHIJKLMNOPQRSTUVWXYZ";main(){ char str[256]; while(cin.getline(str,256)) { if(strcmp(str,"#")==0) break; int chksm=0; for(int i=0;i<strlen(str);i++) chksm+... 阅读全文

posted @ 2012-12-19 13:15 dokc 阅读(121) 评论(0) 推荐(0) 编辑

2012年10月18日

九度1347孤岛连通工程 --并查集kruskal算法

摘要: 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 struct edge 5 { 6 int start,end,len; 7 bool operator < (const edge & a)const 8 { 9 return len<a.len;10 }11 };12 int f[1010],m,n;13 void init(){for(int i=1;i<=n;i++)f[i]=i;}14 int root(int a){w... 阅读全文

posted @ 2012-10-18 14:16 dokc 阅读(163) 评论(0) 推荐(0) 编辑

boj 67 在世界中心呼唤爱

摘要: #include<stdio.h>#include<stdlib.h>struct node{ int data,leftnum,rightnum; node *left,*right;};void insert(node *a,node *b){ if(a->data>b->data) { if(!a->left)a->left=b; else insert(a->left,b); a->leftnum++; } else { if(!a->right)a->right=b; ... 阅读全文

posted @ 2012-10-18 14:12 dokc 阅读(156) 评论(0) 推荐(0) 编辑

九度1377缓变序列

摘要: #include<stdio.h>#include<string.h>int n,m,k,i,j,minN,a[10003];main(){ while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); minN=0x7ffffff,m=0,j=0; for(i=0;i<n;i++)scanf("%d",&k),minN=minN<k?minN:k,a[k]==0?m++:0,a[k]++; if(m==1)printf("NO\n"); e... 阅读全文

posted @ 2012-10-18 14:11 dokc 阅读(149) 评论(0) 推荐(0) 编辑

排序二叉树与三种非递归遍历

摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<stack> 4 using namespace std; 5 struct node 6 { 7 int data; 8 node *left,*right; 9 };10 void insert(node *a,node *b)11 {12 if(a->data>b->data)13 {14 if(!a->left)a->left=b;15 else insert(a->left,b);16 }17 ... 阅读全文

posted @ 2012-10-18 14:10 dokc 阅读(188) 评论(0) 推荐(0) 编辑

导航