经常会在项目中用到 int to string
#include
#include
#include
using namespace std;
int main(void)
{
ostringstream num;
num << 123;
string str = num.str();
cout << str << endl;
return 0;
}...
分类:
编程语言 时间:
2014-07-22 23:04:54
阅读次数:
283
[ 问题: ]
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
[...
分类:
其他好文 时间:
2014-07-22 23:01:35
阅读次数:
331
[ 问题: ]
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were
inserted in order. You may assume no duplicates in th...
分类:
其他好文 时间:
2014-07-22 23:01:15
阅读次数:
270
函数闭包
function createCountdownTimer(second)
local ms=second * 1000;
local function countDown()
ms = ms - 1;
return ms;
end
return countDown;
end
timer1 = createCountdownTimer(1);
for...
分类:
其他好文 时间:
2014-07-22 22:59:53
阅读次数:
307
strassen算法可以看做是分治递归法求解矩阵乘法的改进。
利用分治递归法求解矩阵乘法的过程大致:
矩阵C = A * B(A、B、C都是n x n矩阵)
可以发现(A11 * B11)、(A12 * B21)……等子矩阵的乘法运算需要继续递归。上面有8个乘法,所以需要递归8次。
时间复杂度关系公式 T(n) = 8T(n/2) + O(n^2),这里8T(n/2)是8次递归...
分类:
其他好文 时间:
2014-05-01 08:43:52
阅读次数:
549
1 Yield生成器
Yield是我在其他语言中没有见过的一个属性,算是python的一大特色,用好之后可以使代码更简洁。考虑一个简单的例子,文件的遍历。要遍历一个目录下的所有文件需要递归的操作。如果我们只是单纯的打印文件名,我们可以在递归的过程中完成,每当发现一个非目录就可以打印文件名。代码如下:
class TraverseDirectory(object):
@s...
分类:
编程语言 时间:
2014-04-30 22:48:40
阅读次数:
312
//由于函数是对象,所以可以直接把函数通过参数传递进来;也可以把函数作为返回值。
function calFun(fun,arg){
//第一个参数就是函数对象
return fun(arg);
}
function sum(num){
return num+100;
}
function say(str){
alert("hello "+str);
}
//...
分类:
Web程序 时间:
2014-04-30 22:41:38
阅读次数:
324
进入游戏连连第一个场景,如下:
初始化该场景精灵所需的信息、背景/音效及图层UI
bool HelloWorld::init()
{
//////////////////////////////
// 1. super initfirst
if (!CCLayer::init() )
{
return
false;...
分类:
其他好文 时间:
2014-04-30 22:34:40
阅读次数:
226
示例代码将在注册表位置:HKEY_CURRENT_USER\Software\ 读写键值
bool LicenseManage::OpenRegKey(HKEY& hRetKey)
{
if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,"Software", &hRetKey))
{
return true;
...
分类:
其他好文 时间:
2014-04-30 22:12:40
阅读次数:
195