- 博客(11)
- 收藏
- 关注
原创 Find the Number Occurring Odd Number of Times
<br /> <br />Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space.<br />Example:<br />I/P = [1, 2, 3, 2, 3, 1, 3]<br />O/P = 3<br />Alg
2010-06-08 14:35:00 388
原创 policy-based design
<br />呵呵,有点类似策略模式,不过是用模板实现的。<br />template< typename output_policy, typename language_policy>class HelloWorld : public output_policy, public language_policy{ using output_policy::Print; using language_policy::Message;public:
2010-06-05 15:07:00 390
原创 结束调试后,控制台窗口无法关闭
<br />结束调试后控制台窗口并不关闭,此后不管是点控制台上的关闭按钮、按ctrl+c、任务管理器,甚至是关机,都无法关闭它,只有强行关机。但任务管理器的进程列表中,并没有这个进程。<br /> <br />重装前就这样,重装后也这样,搜了搜,解决方案:<br /> <br />找到问题的原因了,原来是Microsoft security update KB978037 惹的祸,目前解决方法是把它卸载了就可以了。Visual Studio Debugger Team 也正在处理这个问题,希望有其他的解决方
2010-06-03 14:41:00 2383 2
原创 关于单链表的几个有意思的问题
Q1:已知指向单链表的header指针,如何判断该单链表是否存在环?Q2:已知两个单链表,它们可能存在重叠的部分,也就是Y字形链表,如何判断这两个链表是否存在Y字形?Q3:已知指向单链表的header指针,如何高效的输出单链表的倒数第n个节点?(最后一个节点为倒数第0个节点)Q4:不知道单链表的header指针,仅仅知道指向某节点的指针p,如何在链表中删除该节点? 答案在后面
2010-04-29 22:20:00 857
原创 考考你的C++, 猜猜输出啥结果?(2)
int main(){ char ch[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; char *pc = ch; int *pi = (int *)ch; cout << hex << (int)*(pc+2) << /t << *(pi+2) << endl;} 答案在后面:|
2010-04-28 23:53:00 308
原创 考考你的C++, 猜猜输出啥结果?(1)
#include #include using namespace std;class Base{public: virtual void f(int i) { cout << "Base::f(int i)" << endl; } virtual void f(double i) { cout << "Base::f(double i)"
2010-04-28 23:46:00 302
原创 回形方阵算法
回形方阵算法// 21 22 23 24 25 26..// 20 7 8 9 10// 19 6 1 2 11// 18 5 4 3 12// 17 16 15 14 13//观察规律,设数字1点坐标为(0,0),数字7点坐标为(-1,-1)/
2010-04-28 11:19:00 2277
原创 马踏棋盘C++代码
闲来无事,写了一下马踏棋盘的算法,高手莫笑,有问题多指教。 马踏棋盘:在8×8方格的棋盘上,从任意指定方格出发,为马寻找一条走遍棋盘每一格并且只经过一次的一条路径。 #include #include #include using namespace std;class Point{public: Point(size_t x, size_t y):
2010-04-27 19:47:00 1232 2
原创 debug release version through the crash address
Project Setting:1)C/C++:Output Files:Assembler Output:cod file2)Linker:Generate Map File & Map File Name;Record crash address&crash modulenormally, the crash offset address is: crash a
2010-04-16 18:04:00 447
原创 about pack and align for C/C++
http://msdn.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx #pragma pack( n )n : Valid values are 1, 2, 4, 8, and 16.the alignment of a member will be on a boundary that is either
2010-04-15 10:38:00 797
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人