上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页
  2011年7月18日
摘要: 此题依旧是套kruskal()的模板,只是条件有所隐含,此处要自己找出结构体val中的三个参量,并且注意到当距离d可以对应于v;#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>struct zb{ int x,y;}z[110];struct val{ int a,b; double v;}e[10000];int set[110];int c;int m;double sum;int cmp(const void *a,const void *b){ re 阅读全文
posted @ 2011-07-18 16:59 枫叶飘泪 阅读(183) 评论(0) 推荐(0) 编辑
  2011年7月16日
摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int inf=0x7fffffff;int set[110];struct val{ int x,y,v;}e[10000];int n,m;int cmp(const void *a,const void *b){ return ((val *)a)->v - ((val *)b)->v;//注意加括号。 }int find(int a){ return set[a]==a?a:find(set[a]);}int kruskal(){ i 阅读全文
posted @ 2011-07-16 21:10 枫叶飘泪 阅读(250) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int inf=0x7fffffff;int map[210][210],hash[210],dis[210];int n,m,s,t;void dijstra(){ dis[s]=0; for(int i=0;i<n;i++) { int t=inf,pos; for(int j=0;j<n;j++) { if(hash[j]==0) { if(t>dis[j]) { t=dis[j]; pos=j; } } } hash[pos]= 阅读全文
posted @ 2011-07-16 20:45 枫叶飘泪 阅读(151) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int inf=0x7fffffff;int n,m;int map[110][110],hash[110],dis[110];void dijstra(){ dis[1]=0; for(int i=1;i<=n;i++) { int t=inf,pos; for(int j=1;j<=n;j++) { if(hash[j]==0) { if(dis[j]<t) { t=dis[j]; pos=j; } } } hash[pos]=1; 阅读全文
posted @ 2011-07-16 20:24 枫叶飘泪 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>int a[110],b[110],c[110];int cmp(const void *a,const void *b){ return *(int *)b-*(int *)a;}int main(){ int n; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0, 阅读全文
posted @ 2011-07-16 16:08 枫叶飘泪 阅读(266) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int n,m,a[110]; while(scanf("%d%d",&n,&m),n||m) { int j; memset(a,0,sizeof(a)); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } for(int i=0;i<n;i++) { if(a[i]>m) { j=i; break; } } 阅读全文
posted @ 2011-07-16 16:05 枫叶飘泪 阅读(378) 评论(1) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ int n; while(scanf("%d",&n),n) { int sum=0; int m,m1,m2,m3; m1=m2=m3=1; int t; if(n==1) sum=1; else if(n==2) sum=2; else if(n==3) sum=3; else if(n==4) sum=4; else { sum=4; for(int i=5;i<=n;i++) { m=m1 阅读全文
posted @ 2011-07-16 16:01 枫叶飘泪 阅读(437) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#define MAXSIZE 100char a[MAXSIZE];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) { int count=0; memset(a,0,sizeof(a)); scanf("%s",a); int j=MAXSIZE; while(!a[j]) j--; for(int i=j;i>=0;i--) 阅读全文
posted @ 2011-07-16 15:52 枫叶飘泪 阅读(506) 评论(0) 推荐(0) 编辑
摘要: 编辑器加载中...#include<stdio.h>#include<string.h>#include<stdlib.h>int a[110],b[110];int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int main(){ int n; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=0;i<n;i++) { scanf 阅读全文
posted @ 2011-07-16 15:48 枫叶飘泪 阅读(405) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int a[110];int main(){ int m,n; while(scanf("%d%d",&n,&m)!=EOF) { int ave=0,sum=0; memset(a,0,sizeof(a)); for(int i=1;i<=n;i++) { a[i-1]=i*2; } int count=0,c; c=n%m; if(c==0) { for(int i=1;i<=n;i++) { sum+ 阅读全文
posted @ 2011-07-16 15:44 枫叶飘泪 阅读(301) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页