- 博客(21)
- 资源 (4)
- 问答 (4)
- 收藏
- 关注
原创 202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
2016-03-27 23:58:08 373
原创 217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element
2016-03-22 23:04:30 366
原创 258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on
2016-03-22 21:22:18 345
原创 228. Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].Credits:Special thanks to @jianchao.li.fighter
2016-03-22 17:13:24 459
原创 移除容器中与某值相等的元素
1. vector容器1.1 只移除“与某值相等”的第一个元素思路:利用算法寻找该值的位置,删除该位置指向的元素。vector<int> coll;...// 利用<algorithm>提供的算法find(),返回与val值相等的第一个元素(位置)auto pos = find(coll.begin(), coll.end(), val);// 删除与该值相等的第一个元素if(pos !=
2016-03-21 10:58:33 572
原创 242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may a
2016-03-20 22:30:36 271
原创 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you
2016-03-20 17:53:40 381
原创 JAVA面向对象之接口
接口接口是JAVA中最重要的概念,接口可以理解为一种特殊的类;接口中全部是全局常量和公共的抽象方法组成;接口中的抽象方法在其他类中实现,不在接口中实现,因为它们是提供程序员重写方法的,除了可以使用预置的接口,也可以自定义自己的接口;接口的格式inerface inerfaceName{全局常量抽象方法}5. 接口的实现必须通过子类,使用关键字implements,而且接
2016-03-19 00:05:34 539
原创 JAVA面向对象之多态性
多态性的体现方法的重载和重写对象的多态性对象的多态性向上转型:程序自动完成父类 父类对象 = 子类实例向下转型:强制类型转换子类 子类对象 = (子类)父类实例栗子package com.BigoSprite;abstract class A{ public abstract void tell1(); public void tell2(){ System
2016-03-18 23:11:02 483
原创 对抽象类的理解
抽象类的概念(抽象方法)包含一个或多个抽象方法的类就是抽象类,抽象方法为类的成员函数,但不可以是构造和析构函数。成员函数前面加上关键字virtual,该方法就成为抽象方法。抽象类的扩展性特别强,以桂老师的话:抽象基类的方法是以不变应万变。具体是,在抽象基类中定义的抽象方法,在基类中不必实现,而是在派生类中进行实现。抽象类的行为抽象类被子类继承,子类(如果不是抽象类)必须重写抽象类中的所有抽
2016-03-18 21:57:24 589
原创 Cocos2d-x 自己对某场景思路整理
摘要:在这个场景中,菜单项目MenuItem有三个,主要是返回按钮(右上角的×)和向左向右翻的两个箭头。在该场景初始化成员函数中,首先从TEXTURE Package中打包好的文件中加载图片的缓存(创建精灵),然后设置背景精灵的位置,并把该背景精灵添加到该MJLayer层中;然后,秘籍技能界面,同样是基于打包好的缓存来加载图片,以此创建相应精灵,注意使用的API,设置位置等;
2016-03-11 00:30:40 507
原创 Cocos2d-x 第五章,没学完的,没写完的博客,下个礼拜六接着写
简单动作运动之MoveTo和MoveBy// 创建一个精灵对象Sprite* xiaozhi = Sprite::create("xiaozhi.png");// 创建MoveTo动作对象// MoveTo* moveto = MoveTo::create(float duration, const Point& position);// duration为动作执行的时间,单位为秒,const
2016-03-06 23:49:14 380
原创 Cocos2s-x 3.0新成员Value、Vector和Map
ValueValue可以存放“任意”类型的值,任意是在一定范围内,通过Value的所有构造函数来决定使用什么类型的值,如下:例如:Value valStr = Value("This is string type.");Value valInt = Value(250);log("%s%d", valStr.asSting().c_str(), valInt.asInt());注意:调用as**
2016-03-06 21:28:44 790
原创 Cocos2d-x 场景、导演、层、精灵、菜单和节点
场景场景是个虚拟的概念,在Cocos2d-x中场景使用Scene表示,我们可以向场景中添加各种层、精灵、菜单等。场景是游戏的基础,所有的对象都要放在场景中。创建一个场景类对象:auto scene = HelloWord::createScene();场景类源码:class CC_DLL Scene : public Node{public: static Scene *create()
2016-03-06 20:55:26 773
原创 Ranged-Based for loop vs. iterator
基于范围的for循环和迭代器// coll为容器for (type elem : coll){ ...}被解释为:for (auto pos = coll.begin(), end = coll.end(); end != coll.end(); ++pos){ type elem = *pos; ...}
2016-03-05 09:38:39 416
原创 序列式容器List之初始化及其几种(不支持随机)访问形式
#include #include #include using namespace std;void show(char elem){ cout << elem << " ";}int main(){ list coll; // list container for character elements // append elements from 'a'
2016-03-05 00:22:28 1660
原创 copy()作为标准输入设备和标准输出设备之间的数据筛检程序
程序读取一行string,并以一行一个的方式打印它们:#include #include #include #include using namespace std;void main(){ copy(istream_iterator(cin), // begin of sourse istream_iterator (), // end of sourse os
2016-03-03 23:40:05 441
原创 Regex Iterators
These iterators are of type regex_iterator思考下面两点的功能:smatchstr(), str(1), str(2)/* The following code example is taken from the book* "The C++ Standard Library - A Tutorial and Reference,
2016-03-03 13:17:02 638
原创 stream(流) iterator之一个例子
The following example is typical for the power of the whole STL. Compared with ordinary C orC++, the example does a lot of complex processing by using only a few statements:Using vector#incl
2016-03-03 09:40:13 1054 1
原创 Lambdas(C++11新增)
Lambdas 语法no parameters: […] {…}[] { std::cout << "hello lambda" << std::endl; }You can call it directly: [] { std::cout << "hello lambda" << std::endl; } (); // prints ‘‘hello lamb
2016-03-02 17:50:02 642
原创 创建并打开文件
#include #include using namespace std;void main(){ ofstream outfile; outfile.open("test.txt");// 如果没有该文件,将自动创建 if (outfile.is_open()) cout << "文件打开正确!" << endl; else cout << "文件打开失败!" <<
2016-03-01 20:42:00 404
想搭建一款流媒体服务器
2016-03-18
QT做计算器时,把pushButton拖到Grid Layout上
2016-03-17
正则表达式匹配main函数块
2016-03-11
读取文件夹中所有文件的名称(含后缀)
2016-02-17
TA创建的收藏夹 TA关注的收藏夹
TA关注的人