联系
主题 [当前:101 ~ 120, 总共: 132]
Knight's Tale » 技术
“求二进制数中1的个数”的绝妙算法
2010-09-04 23:53
编程之美2.1节中的扩展题第1题:如果变量是32位的Dword,则如何统计该二进制数中1的个数。 对于该题,我原本的想法还是想采用书中解法三,也就是用统计1中个数的算法v&(v-1),该算法时间复杂度为该32二进制数中“1”的个数。 后来,我参见了[1]中的解法,该解法甚妙,复杂度只有若干个位运算,与“1”的数目无关。由于[1]写的比较难懂,所以在这里解释一下他的解法。 解法一: int Co……
继续阅读
寻找最大的K个数
2010-09-03 17:33
这是编程之美书第2.5节的一道题目。 各种解法: 解法一,用nlgn复杂度的排序算法对数组进行从大到小排序,取前K个。但这方法做了两件不必要做的事:它对想得到的K个数进行了排序,对不想得到的n-K个数也进行了排序。方法不可取。 解法二,用选择排序或冒泡排序,复杂度O(NK)。但这方法也做了不必要做的一件事:对想得到的K个数进行了排序。方法不可取。 解法三,用顺序统计位(类快排)算法来计算(可参考算法导论)。算法导论上说这种方法从平均性能上来讲是线性的,但编程之美上却说复杂度……
继续阅读
关于栈、堆、静态存储区最大可分配大小的探讨
2010-09-02 16:49
中午看《编程之美》的第2.5节中有这么一小段程序: float array[100 000 000]; 这个1亿个float变量,这样就有8亿个字节,转化为二进制单位G,就是小于等于1G。这样大小的数组量只能用堆(动态申请内存变量)或者静态存储区(全局变量)来申请。 好了,转入今天要讲的正题。到底栈、堆、静态存储区能申请的最大分配大小是多少呢? 栈(stack) 栈大小与编译器有关。 默认情况下,visual studio 2010 的栈大小为1M。但在平时应用……
继续阅读
有意思的数列: Catalan数*
2010-08-30 23:54
今天晚上小妹问我一个问题, “有一个随意的数组,一个栈,一个队列。现将数组内的元素随机进栈或进队列,等数组中所有元素均在栈中与队列中时,开始出栈和出队列。问题是:这样形成的序列总数有多少种?” 对于这个问题,我现在还没有很确切的解答。要解决这个问题,需先了解如果单独只有栈时,序列有多少种的解决方法。因此,我也花了些时间在“出栈序列”种类问题上,从而发现了非常有趣了“Catalan数”。 【对于小妹的问题,我已经在8月……
继续阅读
[zz]5%的神话(关于开发效率与职业方向)
2010-08-24 13:30
Bruce Eckel(Thinking in Java/C++作者) 在他的 5%的神话 (Mythical 5%) 中提到: 5%的程序员开发效率是其他95%程序员的20倍 (5% of programmers are 20x more productive than the othe……
继续阅读
Somthing about "++i"
2010-08-14 15:28
"++i" return a reference of the "i" object, it's a left-hand value. It's more effective than "i++". int i = 0; ++i =4; std::cout << i << std::enld; // 4 Reference: <a href="http://kni……
继续阅读
[zz]Google的核心技术
2010-08-14 14:03
本篇将主要介绍Google的十个核心技术,而且可以分为四大类: 分布式基础设施:GFS,Chubby和Protocol Buffer。 分布式大规模数据处理:MapReduce和Sawzall。 分布式数据库技术:BigTable和数据库Sharding。 数据中心优化技术:数据中心高温化,12V电池和服务器整合。 分布式基础设施<……
继续阅读
C++ Treasure Index
2010-08-12 15:36
C++拾遗系列(From 2010.10) C++ 拾遗0x201010 <a href="http://knightliao2010.blog.163.com/blog/static/1710151012010953422167/" targe……
继续阅读
The random generator of INT and FLOAT
2010-08-12 00:39
In this example, I show some simple random generator examples using C++. It simulates the generator of INT and FLOAT. The generator format is [a,b] or [a,b). ////////////////////////////////////////////////////////////////////////// // // Test ……
继续阅读
Strategy Design Pattern (C++)
2010-07-15 17:21
This is a C++ project that describe the usage of Strategy Pattern design The aim is to implement one task which is in the page 25 of ( Chinese version ). creatd by Knight 2010.07.15 www.liaoqiqi.com/blog <img class="size-full wp-image-……
继续阅读
Builder Design Pattern and Decorator Design Pattern (C++)
2010-07-14 21:37
This is a C++ project that describe the usage of Builder Pattern design and Decorator Pattern design. The aim is to implement one task which is in the page 614 of ( Chinese version ). File List: Vocation.h : Implement Decora……
继续阅读
How to transfer a graph in visio software into .eps format?
2010-07-11 20:34
Open the .vsd file with Adobe Acrobat Pro software. In Adobe Acrobat Pro software, save the file with .eps format . done.
继续阅读
How to write mathematical formulas with Latex in a short time?
2010-07-11 20:26
Firstly, download a MathType software. [version 6.5 or higher is ok] Secondly, type the formula you need and set Transfer Setttings. See the picture 1. <a href="http://img2.jintiankansha.me/get5?src=http://ww1.sinaimg.cn/m……
继续阅读
How to transfer a graph in .doc into .eps format?
2010-07-11 20:23
Firstly, zoom in the graph in .doc. Secondly, Use QQ or other software to printscreen the graph in .doc Thirdly, paste the printscreen into Photoshop software. Finally, in photoshop software, Save the object int……
继续阅读
Paper Writing Skills with Latex
2010-07-10 16:33
You can reference : http://www.liaoqiqi.com/blog/work/paper-making-technique/ to see my notes about how to make your paper good by using latex. Good Luck!
继续阅读
Paper Making Technique
2010-07-10 11:09
How to transfer a graph in .doc into .eps format? <a href="http://www.liaoqiqi.com/blog/2010/07/11/how-to-write-mat……
继续阅读
Paper Processing~!!!
2010-07-04 00:47
Best wishes for myself! Processing: 2010.08.11 ( we only have -2 days ) Paper & Demo Complete! 2010.08.10 ( we only have -1 days ) Statistics & Demo Making 2010.08.09 ( we only have 0 days ) Statistics……
继续阅读
Be careful of the use of data format in function "scanf"
2010-06-18 23:05
when you use C-sytle scanf function, you should notice the usage of data typpe in "scanf". Everyone knows that "int" data type is an integer, its data format in "scanf" is "%d". So, you may think that "short" type is the same as "int", and you may write c……
继续阅读
Error: already defined in MSVCRT.lib(MSVCR100.dll)
2010-06-17 19:54
If you meet this error in VS, it's because you are mixing code that was compiled with /MD (use DLL version of CRT) with code that was compiled with /MT (use static CRT library). That cannot work, all source code files must be compiled with the same set……
继续阅读
Error: Memory crash _BLOCK_TYPE_IS_VALID(pHead -> nBlockUse)
2010-06-10 00:12
The memory management in C++ is really a headache. This evening I run my program, and get error: "Memory crash _BLOCK_TYPE_IS_VALID(pHead -> nBlockUse)" at runtime. This error may be caused by several reasons: 1. Write buffer overflow[1]. <pre ……
继续阅读