Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) c ...
分类:
其他好文 时间:
2016-03-31 09:29:58
阅读次数:
175
第一次看,看第一节即可 1.我们可以为函数定义一个模板,而不是为每一个类型定义一个函数。 比较函数: #include <iostream> template <typename T> int compare(const T&v1, const T&v2) { if(v1 < v2) return ...
分类:
其他好文 时间:
2016-03-31 07:05:19
阅读次数:
162
为什么要用封装 安全 方便 降低耦合封装的步骤:1.将属性变为private修饰2.写封装的方法 public void setXxx(参数){ //根据处理逻辑给属性赋值 } public 属性类型 getXxx(){ //return 属性值 }访问修饰符 一个.java文件可以定义多个clas ...
分类:
编程语言 时间:
2016-03-31 07:02:26
阅读次数:
190
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 arr ...
分类:
其他好文 时间:
2016-03-31 02:01:34
阅读次数:
183
一,引用类型作为参数1.数组类型作为方法返回值 方法体内return的返回类型与方法定义的返回值类型必须一致。2.数组类型作为参数 调用时方法内的实参为数组为定义方法时的形参类型2.对象类型的参数 对象属于引用数据类型,引用数据类型所传递的值为该对象的地址。 当把一个对象作为参数传递给方法时,其实是 ...
分类:
编程语言 时间:
2016-03-31 02:00:51
阅读次数:
170
一,带参方法1.如何定义带参方法<访问修饰符> 返回类型 <方法名>(<参数列表>){ //方法的主体}访问修饰符:public protected private 返回值类型: 无返回值:void 方法体内没有return 有返回值:数据类型(int,double,String 等) 方法体内必须 ...
分类:
编程语言 时间:
2016-03-31 02:00:30
阅读次数:
145
#include<assert.h>
intsubstr(chardst[],charsrc[],intstart,intlen)
{
intsrcLen=strlen(src);
intleft=0;
assert(dst);
assert(src);
if(srcLen<start)
{
return-1;
}
while(start--)
{
src++;//指针向后偏移start
}
left=srcLen-start;
if(left<len)
{
len=lef..
分类:
其他好文 时间:
2016-03-31 00:21:00
阅读次数:
151
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-neg ...
分类:
其他好文 时间:
2016-03-31 00:10:54
阅读次数:
181
e.g. i love java return java love i ...
分类:
其他好文 时间:
2016-03-30 23:44:38
阅读次数:
205
php server [php] view plain copy <?php require_once('src/Hprose.php'); function hello($name) { echo "Hello $name!"; return "Hello $name!"; } function ...
分类:
编程语言 时间:
2016-03-30 22:05:51
阅读次数:
412