2013年7月26日

摘要: int add(int a,int b){ if(a==0) return b; if(b==0) return a; int m=a^b; // 二进制加法,应当是异或加上与运算 int n=a&b; n=n<<1; if(m&0x1==1) // 为了防止两个数都不收敛于零。事实证明,完全可以收敛 { m=m&~0x1; return 0x1|add(m,n); } return add(m,n);} 阅读全文
posted @ 2013-07-26 21:18 dyc0113 阅读(118) 评论(0) 推荐(0) 编辑
摘要: int CountNumInSortArray(int a[],int n,int key){ if(a==NULL||nkey)j=m-1; else { j=m; isFind=true; if(i==j) break; } } coutkey)j=m-1; else { i=m; } } int end; if(i+1==j&&a[i]==a[j]) { end=j; } else end =i; return end-start+1;} void main(){ int a[]={1,2,3,3,3,3,4,5}; try { int num... 阅读全文
posted @ 2013-07-26 13:53 dyc0113 阅读(176) 评论(0) 推荐(0) 编辑

导航