bool HelloWorld::init(){ ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Si...
分类:
其他好文 时间:
2014-12-07 09:00:36
阅读次数:
290
To decide who would play first in a human vs. AI chess match,the human contender, Garry, suggested flipping a coin. 为了决定谁在人机象棋比赛里有先走权,嘉里说,抛硬币决定。Heprod...
分类:
其他好文 时间:
2014-12-07 06:29:17
阅读次数:
303
Jump Game II Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represent...
分类:
其他好文 时间:
2014-12-06 22:42:02
阅读次数:
235
对于传统的二分查找,若能找到,则返回target的下标,若找不到则返回-1后,退出函数。齐代码比较简单,如下:int bSearch(vec vec, int start,int end,int target){ int first = start,last = end,mid; whi...
分类:
其他好文 时间:
2014-12-06 20:16:48
阅读次数:
275
题目大意:题意很明确,就是约瑟夫环。不过从第W个位置开始计数1,数S个
位置,然后出环,输出。
思路:用STL里边的string存放小孩的名字。用list双向链表模拟约瑟夫环。
注意:
string里边clear();用来清除所有字符。
list里push_back(i);用来将编号i放入list
begin();指向第一个元素的位置
end();指向最后一个元素后边的位置
list::iterator it;迭代器用来指向报数编号。
find(first,last,value);用来在区间[fi...
分类:
其他好文 时间:
2014-12-06 18:13:16
阅读次数:
237
题目
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
解答
注意假的头结点的运用,代码如下:
/**
* Definition for singly-...
分类:
其他好文 时间:
2014-12-06 16:51:45
阅读次数:
195
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41750865
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
For example,
Given 1->2->3,4->5->6,...
分类:
其他好文 时间:
2014-12-06 08:55:36
阅读次数:
245
《算法》中二叉查找树一节的习题:按层遍历二叉查找树。可以使用队列来管理二叉查找树中的节点,节点按照如下方法入队出队:节点x入队当队列不为空时使用队列的第一个元素first如果节点first.left不为空则将fisrt.left入队如果节点first.right不为空则将first.right入队将...
分类:
其他好文 时间:
2014-12-06 00:00:43
阅读次数:
380
1 Reada set of integers into a vector. Print the sum of each pair of adjacent elements.Change your program so that it prints the sum of the first and last elements,followed by the sum of the second an...
分类:
编程语言 时间:
2014-12-05 21:17:08
阅读次数:
314
Problem DescriptionYour task is to Calculate a + b.InputInput contains an integer N in the first line, and then N lines follow. Each line consists of ...
分类:
其他好文 时间:
2014-12-05 21:00:44
阅读次数:
327