摘要: #include<stdio.h >#include<malloc.h>#define OK 1#define ERROR 0typedef struct BiTNode{char data;struct BiTNode *lChild,*rChild;}BiTNode,*BiTree;//二叉树的初始化函数int Initiate(BiTree bt)//二叉树的头结点 { bt = (BiTree )malloc(sizeof(BiTNode)); if(bt==NULL) return 0; bt->lChild=NULL; bt->rChild=NU 阅读全文
posted @ 2011-08-11 17:07 bcy 阅读(760) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>typedef struct tree{ int num; struct tree *lchild,*rchild;}tree;tree *creatree(){ int num; tree *T; scanf("%d",&num); if(num==0) T=NULL; else { T=(tree*)malloc(sizeof(tree)); T->num=num; T->lchild=creatree(); T->rchild=creatree(); 阅读全文
posted @ 2011-08-11 17:06 bcy 阅读(210) 评论(0) 推荐(1) 编辑
摘要: #include <cstdio>#include <cmath>int N;bool isp(int n){ if( n <= 1 ) return 0; if( n == 2 ) return 1; int i , t = sqrt(n); for(i = 2 ; i <= t ; i++) if(n%i == 0) return 0; return 1;}void dfs(int n, int len){ if(len == N) { printf("%d\n",n); return; } else { int i ; for(i 阅读全文
posted @ 2011-08-11 17:05 bcy 阅读(151) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>int n,num[10000],dis[10000];int cal( ){ int Max = 0; for( int i = 1; i <= n;++i ) { int max = 0,pos = 0; for( int j = 0; j <= i; ++j )//找前面已经存在且符合条件的最优解 if( dis[j] > max && num[j] < num[i] ) max = dis[j]; dis[i] += num[i] + max;//找到后 阅读全文
posted @ 2011-08-11 16:59 bcy 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"stdlib.h"#include"string.h"#include"math.h"int sushu(int x){ int t=(int)sqrt(x+1); for(int j=2;j<=t;j++) { if(x%j!=0) return 1; else { break; return 0; } }}int main(){ int N,k,cnt,max; while(scanf("%d",&N)!=EOF) { whi 阅读全文
posted @ 2011-08-11 16:56 bcy 阅读(176) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"stdlib.h"#include"math.h"#include"string.h"double diss(int x1,int x2,int y1,int y2){ int dis=0; return (sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); }int main(){ int x,y,n,map[1010][1010]; double sum[1010]={0},dis[1010]={0}; while(scanf(&q 阅读全文
posted @ 2011-08-11 16:51 bcy 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"string.h"int map[25][25],des[25][25],n,m,sx,sy;void DFS(int y,int x){ if(map[y][x]=='#'||des[y][x]||y>n||x>m) return ; des[y][x]=1; DFS(y-1,x); DFS(y+1,x); DFS(y,x-1); DFS(y,x+1); }int main(){ while(scanf("%d%d*c",&m,&n),n 阅读全文
posted @ 2011-08-11 16:48 bcy 阅读(159) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h"#include"string.h"#include"stdlib.h"#include"math.h"#define MAXSIZE 10000000int prim[MAXSIZE+5];void fun(){ memset(prim,0,sizeof(prim)); prim[0]=prim[1]=1; for(int i=4;i<=MAXSIZE;i+=2) { prim[i]=1; } double t=sqrt(MAXSIZE); for(int i=3;i< 阅读全文
posted @ 2011-08-11 16:24 bcy 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 题意:给出N个数,将其中重复出现的去掉,再将新的序列进行排序输出;#include<stdio.h> #include<stdlib.h> int cmp(const void *a, const void *b) { return *(int *)a-*(int *)b; } int main() { int a[101]; int b[101]={0}; int m; int k=0; while(scanf("%d",&m)!=EOF) { int i,j; for(i=0;i<m;i++) scanf("%d" 阅读全文
posted @ 2011-08-11 16:22 bcy 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #include"iostream"#include"cstdlib"#include"cmath"using namespace std;const int MAX=1000;int main(){ int i=0,j=0,n=sqrt(MAX)+1; int a[MAX+1]={0}; for(i=2;i<=n;i++) a[j*i]=1; for(i=2;i<=MAX;i++) if(a[i]==0) { cout.width(7); cout<<i<<""; } //sy 阅读全文
posted @ 2011-08-11 16:04 bcy 阅读(120) 评论(0) 推荐(0) 编辑