上一页 1 2 3 4 5 6 7 8 ··· 24 下一页
摘要: 由于c没有重载 c++有重载,c++翻译名字时通过函数名+参数,加extern “c”是采用c调用方式,从而链接正确的函数。 阅读全文
posted @ 2013-09-13 23:56 l851654152 阅读(183) 评论(0) 推荐(0) 编辑
摘要: int*(*f[10])(int*) 阅读全文
posted @ 2013-09-13 23:19 l851654152 阅读(189) 评论(0) 推荐(0) 编辑
摘要: /* return 1 if string contain only digits, else return 0 */ int valid_digit(char *ip_str) { while (*ip_str) { if (*ip_str >= '0' && *ip_str = 0 && num <= 255) { /* parse remaining string */ ptr = strtok(NULL, DELIM); if (ptr != NULL) ... 阅读全文
posted @ 2013-09-13 22:43 l851654152 阅读(6068) 评论(0) 推荐(0) 编辑
摘要: 1. 楼梯有n个台阶,上楼可以一步上1阶,也可以一步上2阶,一共有多少种上楼的方法?斐波那契数列 第一项为1 第二项为2 也就是f(n)=f(n-1)+f(n-2),用递归求。给个分析的例子:有一个11级的台阶,一个人可走一步也可走两步,问这个人有多少种方法走完这个台阶?解:①只用一步走:1+1+1+1+1+1+1+1+1+1+1=11,共11步,只有C11,1=1种走法。②用了一次两步走:1+1+1+1+1+1+1+1+1+2=11,共10步,有C10,1 =10种走法。③用了两次两步走:1+1+1+1+1+1+1+2+2=11,共9步,有C9,2 =36种走法。④用了三次两步走:1+1+. 阅读全文
posted @ 2013-09-13 22:16 l851654152 阅读(10172) 评论(1) 推荐(2) 编辑
摘要: 有81匹马,9个赛道,问至少比赛多少次可以取跑的最快的前四名?可以这么考虑,先赛九场,可得到每场最快的马,再将这九匹每组最快的马再赛一次,得到跑的最快的马,然后踢出最快的马,并将踢出的马所在的那组第二快的马补上,再将赛这九匹马,然后踢出最快的马,此时踢出的马为全部马中第二快的马,依次类推,所以总共要赛9+4=13次。 阅读全文
posted @ 2013-09-13 21:28 l851654152 阅读(358) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include using namespace std;bool cmp(int a,int b){ return a>b;}int main(){ int n; cin >>n; int num[65536]={0}; for (int i = 1;i 0) { count++; } } cout << count <<endl; return 0;} 阅读全文
posted @ 2013-09-12 23:08 l851654152 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 算法#include #include #include #include #include #include using namespace std;bool cmp(int a,int b){ return a>b;}int main(){ int num[10]; for (int i = 0;i>num[i]; } sort(num,num+10,cmp); int i = 0; for (i = 0;i<10;i++) { if (num[i] <= 60) { break; } } if (i==10) { cout << "60&qu 阅读全文
posted @ 2013-09-12 22:31 l851654152 阅读(135) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/pkuoliver/archive/2010/10/27/Convert-m-number-to-n-number.html从这道题中可以看出,数论中存在很大一部分是通过除以基数和取模来操作来得到单个的数,时间相加问题也是如此。 阅读全文
posted @ 2013-09-10 22:29 l851654152 阅读(187) 评论(0) 推荐(0) 编辑
摘要: bool isEven(int n){ return (n&1) == 0;}int gcd(int *a,int length){ int *pbegin = a; int *pend = a + length -1; while(pbegin < pend) { if (!isEven(*pbegin)) { pbegin++; continue; } if (isEven(*pend)) { pend--; continue; } int temp = *pbegin; *pbegin = *pend; *pend = temp; } return 0;... 阅读全文
posted @ 2013-09-03 23:56 l851654152 阅读(431) 评论(0) 推荐(0) 编辑
摘要: int gcd(int x,int y){ return (!y)?x:gcd(y,x%y);} 阅读全文
posted @ 2013-09-03 23:50 l851654152 阅读(303) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 24 下一页