摘要:
1.数组求和如果只是普通求和会简单,但是只能使用一行代码该怎么办呢?int sum(int *a,int n){ return n ==0 ? 0 : sum(a,n-1) + a[n-1]; }2.寻找发帖水王int Find(int *a,int n){ int times = 0; int value; for (int i = 0;i max) { max = a[i]; } if (a[i] max) { max = a[i]; } if (a[i] sum) { ahead--; } else { behind++; } }}int main... 阅读全文
posted @ 2013-08-26 13:01
l851654152
阅读(319)
评论(0)
推荐(0)
摘要:
可以利用额外的空间则可以遍历两次时间复杂度O(N) 空间复杂度O(1)void Translate(int a[], int b[], int n){ b[0] = 1; for (int i = 1; i = 1; i--) { b[i] *= b[0]; b[0] *= a[i]; }} 阅读全文
posted @ 2013-08-26 12:53
l851654152
阅读(199)
评论(0)
推荐(0)
摘要:
2 阅读全文
posted @ 2013-08-26 02:04
l851654152
阅读(145)
评论(0)
推荐(0)
摘要:
1 阅读全文
posted @ 2013-08-26 02:00
l851654152
阅读(197)
评论(0)
推荐(0)
摘要:
1.去掉重复字符串时间复杂度为O(n)#include using namespace std;int main(){ char str[] = "bdsjiseftftftfyrzsesese"; int length = strlen(str); char *p = str; char hashTable[256] = {0}; for (int i = 0;i using namespace std;int main(){ char *str = "edsjiseftftftfyrzsesese"; char *p = str; char hash 阅读全文
posted @ 2013-08-26 00:06
l851654152
阅读(868)
评论(0)
推荐(0)

浙公网安备 33010602011771号