- 博客(36)
- 资源 (3)
- 收藏
- 关注
转载 Cocos 给精灵着色
http://brandontreb.com/cocos2d-tutorial-dynamically-coloring-sprites
2015-03-20 11:40:59
805
原创 Cocos-2dx 3.x Android 开发环境的搭建
注意:本指南主要以Cocos2d-x 3.x版本引擎为例。 在Windows 7平台搭建Android Cocos2d-x开发环境不难,但因为框架更新频繁,许多用户在使用过程中还是会遇到很多问题。希望本指南对用户有好处。 建议:为避免安全相关问题,所有操作请在管理员身份下进行,在运行命令时,请确保以管理员身份打开控制台(console)。 本指南将介绍如何在Windows
2015-02-16 17:39:15
1470
转载 X86汇编快速入门
本文翻译自:http://www.cs.virginia.edu/~evans/cs216/guides/x86.html 本文描述基本的32位X86汇编语言的一个子集,其中涉及汇编语言的最核心部分,包括寄存器结构,数据表示,基本的操作指令(包括数据传送指令、逻辑计算指令、算数运算指令),以及函数的调用规则。个人认为:在理解了本文后,基本可以无障碍地阅读绝大部分标准X86汇编程序。当然,更复
2015-01-03 21:46:41
641
转载 浮点数精度
printf("%.2lf",a);//这里是将a四舍五入输出 计算几何头疼的地方一般在于代码量大和精度问题,代码量问题只要平时注意积累模板一般就不成问题了。精度问题则不好说,有时候一个精度问题就可能成为一道题的瓶颈,简直“画龙点睛”。这些年的题目基本是朝着越来越不卡精度的方向发展了,但是也不乏一些%^&%题#$%$^,另外有些常识不管题目卡不卡,都是应该知道的。今天我就开膛回顾
2014-12-29 22:28:15
646
转载 读写锁实现
一、使用互斥锁和条件变量实现读写锁: [cpp] view plaincopy class readwrite_lock { public: readwrite_lock() : stat(0) { } void readLock()
2014-12-13 21:59:44
871
原创 leetcode:Trapping Rain Water
class Solution { public: int trap(int A[], int n) { if(n <= 0) return 0; int * water = new int[n]; int current =0; for(int i=0 ;i<n;i++) {
2014-11-29 15:31:34
424
原创 leetcode:First Missing Positive
class Solution { public: int firstMissingPositive(int A[], int n) { for(int i =0 ;i < n;i++) { if(A[i] 0) { int temp = A[i];
2014-11-29 15:25:51
393
原创 leetcode:Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combina
2014-11-29 15:19:47
419
原创 leetcode:Valid Sudoku
class Solution { public: bool isValidSudoku(vector > &board) { int n = board.size(); if(n != 9) return false; int m = board[0].size(); if(m != 9)
2014-11-27 22:58:29
442
原创 leetcode:Search Insert Position
class Solution { public: int searchInsert(int A[], int n, int target) { int ans = n; int begin = 0, end = n-1; while(begin <= end) { int mid = begin + (
2014-11-27 22:30:58
415
原创 leetcode:Search for a Range
class Solution { public: vector searchRange(int A[], int n, int target) { vector result; result.push_back(leftBound(A,n,target)); result.push_back(rightBound(A,n,target));
2014-11-27 22:24:54
450
原创 leedcode:Search in Rotated Sorted Array
class Solution { public: int search(int A[], int n, int target) { int begin = 0, end = n-1; int ans = -1; while(begin <= end) { int mid = begin + (end -
2014-11-27 21:22:07
400
原创 leetcode:Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()",
2014-11-26 22:36:21
424
原创 morris 树的中序遍历(O(1)空间 O(n)时间)
#include using namespace std; struct TreeNode { int val; TreeNode * left; TreeNode * right; TreeNode(int v):val(v),left(NULL),right(NULL){} }; void InorderTraversal(TreeNode * root) { if(ro
2014-11-20 22:57:32
503
原创 leetcode:Binary Tree Preorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Soluti
2014-11-19 21:25:34
433
原创 leetcode:Linked List Cycle II
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *de
2014-11-19 21:21:00
414
原创 leetcode:Single Number II
class Solution { public: int singleNumber(int A[], int n) { int sign = 0; long long ret = 0; for(int i = 0; i < n ;i++) { long long c = A[i];
2014-11-19 20:33:54
422
原创 leetcode:Copy List with Random Pointer
/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(int x) : label(x), next(NULL),
2014-11-18 22:32:00
427
原创 leetcode:Reorder List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void reorder
2014-11-18 22:17:39
405
原创 leetcode:Candy
class Solution { public: int candy(vector &ratings) { int n = ratings.size(); int c = 1; int * num = new int[n]; num[0] = 1; for(int i = 1; i < n; i++)
2014-11-18 22:02:39
408
原创 leetcode:Word Break
class Solution { public: bool wordBreak(string s, unordered_set &dict) { int n = s.length(); if(n == 0) return true; bool * canBreak = new bool[n]; mems
2014-11-18 21:54:11
305
原创 leetcode:Binary Tree Postorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Soluti
2014-11-18 21:44:35
430
原创 leetcode:Min Stack
class MinStack { public: stack ele; stack minStack; void push(int x) { int minVal = x; if(minStack.empty() == false) minVal = min(x, minStack.top());
2014-11-18 21:34:26
445
原创 二叉树的最小公共祖先(一次查询)
#include using namespace std; struct Node { int val; Node * left; Node * right; Node(int v):val(v),left(NULL),right(NULL){} }; Node * lca(Node * a, Node * b, Node * root, int & appNum ) { i
2014-11-18 21:19:18
960
原创 最小公共祖先(LCA)离线算法_Tarjan c++实现
#include #include #include #include using namespace std; struct Node { int val; vector chlidren; Node(int v):val(v){} }; class UnSet { public: UnSet(int n):capacity(n) { father = new int
2014-11-18 20:40:57
1309
原创 leetcode:Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a sorted array is rotated at some pivot unk
2014-11-03 22:40:24
497
原创 Leetcode:Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in
2014-11-03 22:16:00
506
转载 float与double的范围和精度
1. 范围 float和double的范围是由指数的位数来决定的。 float的指数位有8位,而double的指数位有11位,分布如下: float: 1bit(符号位) 8bits(指数位) 23bits(尾数位) double: 1bit(符号位) 11bits(指数位) 52bits(尾数位) 于是,float的指数范围为-127~+128,而dou
2014-08-07 14:14:49
494
原创 Cocos2d-x源码解析(1)——地图模块(2)
接上一章《Cocos2d-x源码解析(1)——地图模块(1)》 首先TMX文件本身就是XML格式,
2014-06-19 14:40:20
876
原创 Cocos2d-x源码解析(1)——地图模块(1)
cocos通过载入tiled 生成的tmx文件来生成游戏地图,本文主要分析cocos载入地图模块的源码。 如图所示,地图载入模块由以上几个类组成。 对外的入口是类CCTMXTiledMap,在使用该类时,程序员不需要知道其底层的其他类便可解析tmx文件生成地图。 那么,我们首先分析类CCTMXTiledMap是如何调用其他类进行解析,该类的声明如下: class CC_DLL CCT
2014-06-18 17:17:07
1386
原创 cocos2d-x 入门——hello world 解析
接下来我们来看,AppDelegate的代码。 先看申明 class AppDelegate : private cocos2d::CCApplication { public: AppDelegate(); virtual ~AppDelegate(); /** @brief Implement CCDirector an
2014-02-21 17:13:41
638
原创 cocos2d-x 入门——环境的部署
官网: http://www.cocos2d-x.org/ 里面有一个cocos2d-win32.vc2012.sln的文件 用visual studio打开(根据自己的版本号) 因为安卓 iphone什么的太麻烦 就先从win32开始吧 (反正可以跨平台没事) 这个工程, 就是hello world(设置成启动项就可以直接编译运行) 然后te
2014-02-21 16:50:09
584
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅