上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页
摘要: View Code 1 #include<stdio.h>//二分搜索技术运用。此题在排序后应用减法从右往左。 2 #include<stdlib.h> 3 #include<string.h> 4 5 int a[1001],i,j,k,ncases; 6 int search(int num,int from,int end) 7 { 8 int mid; 9 while(from <= end) 10 { 11 mid = (from+end)/2; 12 if(num == a[mid])13 return... 阅读全文
posted @ 2012-08-01 23:15 zhongya 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 思路很简单,给你n个数和一个sum要求从n个数中选出所有加和为sum的数值串:肯定是先用DFS找出所有的情况然后再删掉重复的;这里我从课件里学到一种判断重复的方法,把核心代码附上:void findSum (int sum, int iEnd, int numSkipped) { if (iEnd == listlength) return; int newsum = sum - list[iEnd]; //取第iEnd个数 if ((numSkipped != list[iEnd])&&(newsum >= 0)) { used[iEnd] = 1; //标记第iEnd 阅读全文
posted @ 2012-06-07 14:52 zhongya 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 求周长,一开不知道怎么求,最后钻到POJ讨论区内,看到一种方法,就是‘X"周围全换成0,最后只要求0的个数就好了嗯,这种方法真好,反正我们想起来,膜拜啊!这题过了从网上搜了下发现可以用BFS做,想想也是,本身用那一种都行View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 #include<ctype.h> 6 7 int map[25][25],f[25][25],visit[25][25], 阅读全文
posted @ 2012-06-04 23:25 zhongya 阅读(155) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<math.h> 5 #include<ctype.h> 6 7 int len; 8 long n,num; 9 char s[15]; 10 void DFS(int t,long ans)11 {12 int i; 13 if(t == len)14 { 15 if(ans == n) 16 num++; 17 return ; 18 }... 阅读全文
posted @ 2012-06-04 23:19 zhongya 阅读(217) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 #include<ctype.h> 6 7 char map[101][101]; 8 int visit[101][101],m,n; 9 int dx[] = {0,1,-1, 0,1, 1,-1,-1}; 10 int dy[] = {1,0, 0,-1,1,-1,-1, 1};11 12 void DFS(int x,int y)13 {14 阅读全文
posted @ 2012-06-04 23:17 zhongya 阅读(170) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 4 long min = 99999999; 5 int main() 6 { 7 int i,a,b,m; 8 long n,sum,x; 9 10 scanf("%ld%d",&n,&m); 11 sum = -1; 12 for(i=0; i<m; i++)13 {14 scanf("%d%d",&a,&b); 15 x = (n*b)/(a+b) + 1; 16 ... 阅读全文
posted @ 2012-05-31 19:30 zhongya 阅读(137) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 5 char s[1000]; 6 int main() 7 { 8 int i,len; 9 10 while( gets(s) )11 { 12 printf("%s\n",s); 13 } 14 15 return 0;16 } 阅读全文
posted @ 2012-05-31 19:29 zhongya 阅读(77) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<ctype.h> 5 6 int main() 7 { 8 int i,j,ncases,J=0,C=0; 9 int k,len,ok;10 char s[201]; 11 12 scanf("%s",s); 13 len = strlen(s);14 for(i=0; i<len; i++)15 {16 if(isupper(s[i]))17 ... 阅读全文
posted @ 2012-05-31 19:27 zhongya 阅读(175) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 int main() 6 { 7 int ncases,sum,a,i,len,k; 8 char s[8]; 9 10 scanf("%d",&ncases); 11 while(ncases--)12 { 13 scanf("%s",s); 14 len = strlen(s); 15 for(i=0; i<len; i++) 16 ... 阅读全文
posted @ 2012-05-31 19:25 zhongya 阅读(161) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 5 int main() 6 { 7 int i; 8 double a,n,b,sum; 9 sum = 0.0; 10 for(i=0; i<12; i++)11 {12 scanf("%lf",&a);13 sum += a;14 } 15 n = floor(sum); 16 if(sum-n >= 0.500000) 17 ... 阅读全文
posted @ 2012-05-31 19:24 zhongya 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页