摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h>//回溯法运用。模拟汉诺塔过程 3 4 int flag; 5 void hanor(int n,int *a,int *b,int *c) 6 { 7 int i; 8 if(!flag) 9 return ;10 if(n == 0)11 {12 flag = 1;13 return ;14 } 15 if(n == b[1])16 {17 f... 阅读全文
posted @ 2012-08-01 23:18 zhongya 阅读(163) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 char s1[1001],s2[1001]; 6 int cmp (const void *a,const void *b) 7 { 8 if( *(char*)a < *(char *)b ) 9 return 1;10 return -1;11 }12 13 int main()14 {15 int i,j,k,len;16 17 while(scanf("%s",s1)... 阅读全文
posted @ 2012-08-01 23:16 zhongya 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑