码迷,mamicode.com
首页 >  
搜索关键字:return    ( 60766个结果
从python的yield说起
前段时间在读trac中wiki模块的源码的时候,发现了很多地方都使用了yiled这一关键词,感觉是在需要返回某个值的地方通过yield来代替return,不是很明白其用法,所以仔细研究下。一个使用了yiled关键字的函数就不再是一个普通的函数了,而是一个生成器函数(generator functio...
分类:编程语言   时间:2014-10-10 18:06:04    阅读次数:231
交集去重
public class jiaoji { /** * @param args */ public static void main(String[] args) { String s1="abc"; String s2="abdgca"; System.out.println...
分类:其他好文   时间:2014-10-10 17:36:24    阅读次数:164
Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:其他好文   时间:2014-10-10 16:26:13    阅读次数:141
数组奇在偶前
public class shuzujizaihouzhiqian { //private static final String[][] String = null; /** * @param args * @return */ public static void sort(int[]...
分类:编程语言   时间:2014-10-10 16:08:50    阅读次数:169
(原创) cocos2d-x 3.0+ lua 学习和工作(4) : 公共函数(2): 检查
这里的函数主要用来做:检查操作。参考资料为quick_cocos.星月倾心贡献~~~--[[-- 检查并转换为数值,转换失败则返回 0-- @param value 要检查并转换的值-- @param base 进制,默认为十进制-- @return number 返回的数值--]]function...
分类:其他好文   时间:2014-10-10 15:59:00    阅读次数:153
Spiral Matrix
[leetcode]Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order....
分类:其他好文   时间:2014-10-10 15:11:54    阅读次数:139
UVa 679 - Dropping Balls
题目:有一颗满二叉树,每个节点是一个开关,初始全是关闭的,小球从顶点落下,             小球每次经过开关就会把它的状态置反,现在问第k个球下落到d层时经过的开关编号。 分析:进制编码。经过模拟几次可以看出,球会让开关形成连续二进制数的表示(根是低位)。             当放入第k个球时,开关状态正好是二进制的k,利用模2的余数判断走向即可。 说明:观察规律模拟处理即可。...
分类:其他好文   时间:2014-10-10 15:02:02    阅读次数:233
Java 实现享元(Flyweight)模式
/** * 字母 * @author stone * */ public class Letter { private String name; public Letter(String name) { this.name = name; } public String getName() { return name; } }/** * 一个产生字母对象的 享元工...
分类:编程语言   时间:2014-10-10 14:46:14    阅读次数:182
用123456789,建3个3位数,数值比为1:2:3
public class mylin { /** * @param args */ public static void main(String[] args) { int n1 = 0; int n2 = 0; for (int i = 123; i ...
分类:其他好文   时间:2014-10-10 14:33:04    阅读次数:158
Longest Substring Without Repeating Characters
这题看起来挺简单的,就是存一个哈希表,然后依次遍历整个字符串,遇到前面有过的字符的时候,就该停止当前计数,新的子串应该从发现该字符的位置的下一位置开始。我开始写了一个简单的写法,发现超时了: if (s.empty()) return 0; if (s.length() == 1) retur.....
分类:其他好文   时间:2014-10-10 14:28:10    阅读次数:160
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!