摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int N, M, map[1010][1010], dis[1010], hash[1010], cnt, dp[1010];const int inf = 0x7fffffff;void Dijsktra () { dis[2] = 0; for ( int i = 1; i <= N; i++ ) { int pos, t = inf; for ( int j = 1; j <= N; j++ ) { if ( hash[j] == 0 阅读全文
posted @ 2011-08-11 17:16 bcy 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>const int inf = 0x7fffffff;int st[110], rank[110], N, M, x, y, val, maxN, map[110][110];struct Edge { int x, y, val;}e[10000];int cmp ( const void *a, const void *b ) { return (( Edge * )a)->val - ( ( Edge * )b )->val; } 阅读全文
posted @ 2011-08-11 17:15 bcy 阅读(173) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>struct T { T * ch[26]; int n, flag;}rt;char in[15];void init ( T * t ) { for ( int i = 0; i < 26; ++ i ) t->ch[i] = NULL; t->n = t->flag = 0;}void insert ( T *t, char *in ) { if ( *in ) { if ( t->ch[ *in - ' 阅读全文
posted @ 2011-08-11 17:14 bcy 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int n,m,map[124][124];int inf = 0x7fffffff;void floyd( ){ for( int i = 1; i <= n; ++i ) for( int j = 1; j <= n; ++j ) for( int k = 1; k <= n; ++k ) if( map[i][j] != inf && map[i][k] != inf ) if( map[i][j] + map[i][k] < map[j][k] ) map[j][k] = map[i][j] + ma 阅读全文
posted @ 2011-08-11 17:14 bcy 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>int set[100000],b[100000];int find(int x){return (x==set[x])?x:set[x]=find(set[x]);}int main(){ int n,x,y,max,X,Y; while(scanf("%d",&n)!=EOF){ for(int i=0;i<100000;i++) { set[i]=i;b[i]=1; } for( int i=0;i<n;i++){ scanf("%d%d&quo 阅读全文
posted @ 2011-08-11 17:13 bcy 阅读(150) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int n,m,num[100024];int cmp( const void *a,const void *b ){ return *( int * )b - *( int * )a;}int main( ){ while( scanf( "%d%d",&n,&m ) , n | m ) { for( int i = 0; i < n; ++i ) scanf( "%d",&num[ 阅读全文
posted @ 2011-08-11 17:12 bcy 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>char s1[15], s2[15];long long int abc ( char *s ) {long long int sum;int length = strlen ( s );for ( int i = 0; i < length; i++ ) { if ( s[i] == ',' ) {for ( int j = i; j < length-1 ; j++ ) { s[j] = s[j+1];} s[lengt 阅读全文
posted @ 2011-08-11 17:11 bcy 阅读(158) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>#define MAXSIZE 100000typedef int DataType;typedef struct{DataType data[MAXSIZE];int last;}Seqlist;Seqlist *L;void init_Seqlist(){L=(Seqlist *)malloc(sizeof(Seqlist));L->last=-1;}void va(){ int t; for(int i=0;i<=L->last/2;i++){t= L->data[i]; 阅读全文
posted @ 2011-08-11 17:10 bcy 阅读(175) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<iostream.h>#define MAXSIZE 1024typedef char DataType;typedef struct{ DataType data[MAXSIZE]; int top;}SeqStack;SeqStack *s;SeqStack *Init_SeqStack(){ SeqStack *s; s=new SeqStack; if(!s) { printf("空间不足\n");return NULL; } else { s->top=-1;return s; }} 阅读全文
posted @ 2011-08-11 17:09 bcy 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<iostream.h>#define MAX 1000typedef int DataTypetypedef struct{ DataType data[MAX];int last;}SeqList;int Delete_SeqList(SeqList * L){ int i,j,k; DataType temp; for(i=1;i<=L->last;i++) { temp=L->last; for(j=2;j<=L->last;j++) { if(temp=L->last[j]) 阅读全文
posted @ 2011-08-11 17:08 bcy 阅读(302) 评论(0) 推荐(0) 编辑