代码改变世界

阅读排行榜

print a complete binary tree anti-clockwise

2010-10-01 20:46 by wansishuang, 313 阅读, 收藏,
摘要: Print all edge nodes of a complete binary tree anti-clockwise. That is all the left most nodes starting at root, then the leaves left to right and finally all the rightmost nodes.In other words, print... 阅读全文

Determining if a point lies on the interior of a polygon

2010-10-02 13:51 by wansishuang, 307 阅读, 收藏,
摘要: ZZ http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/Determining if a point lies on the interior of a polygonWritten by Paul BourkeNovember 1987Solution 1 (2D)The following is a simple solutio... 阅读全文

a zig-zag array

2010-10-05 11:14 by wansishuang, 300 阅读, 收藏,
摘要: Produce a zig-zag array. A zig-zag array is a square arrangement of the first N2 integers, where the numbers increase sequentially as you zig-zag along the anti-diagonals of the array. For a graphical... 阅读全文

assignment operator:对class中const成员变量赋值

2010-09-26 19:19 by wansishuang, 283 阅读, 收藏,
摘要: #include using namespace std; class Test { public: Test(int _a):a(_a) { } Test& operator=(const Test& ra) { if(&ra != this) { const_cast(a) = ra.a; ... 阅读全文

Sort an array

2010-09-25 16:11 by wansishuang, 261 阅读, 收藏,
摘要: You are given an array of positive integers. Convert it to a sorted array with minimum cost. Only valid operation are1) Decrement -> cost = 12) Delete an element completely from the array -> cos... 阅读全文