先整体翻转一次,再一个个进行翻转,需要注意的是代码里一些字符串的操作,值得记住。 1 class Solution { 2 public: 3 string ReverseSentence(string str) { 4 if (str.empty()) return str; 5 reverse( ...
分类:
其他好文 时间:
2016-03-27 15:20:54
阅读次数:
133
1 def outer(fun): # f 为用out装饰的函数 2 def inner(): 3 print('装饰器!') 4 fun() 5 print('test') 6 return inner 7 8 @outer 9 def fun1(): 10 print('fun1') 11 12 ...
分类:
编程语言 时间:
2016-03-27 14:08:33
阅读次数:
160
找了一个通用的 ThinkPHP 数据库的配置文件,用来连接数据库的,比较简单,适合企业站点,配置的参数很少,这样在建立企业类型等小网站的时候就可以直接使用了,如下代码. <?phpif(!defined('THINK_PATH')) exit();return $array = array ('D ...
分类:
数据库 时间:
2016-03-27 11:07:07
阅读次数:
209
首先我们先编写魔兽系统中的用户信息类(LoginInfo)用来存放属性 封装属性代码: //电子邮箱 private string email; public string Email { get { return email; } set { email = value; } } //身份证号码 ...
分类:
其他好文 时间:
2016-03-27 10:54:40
阅读次数:
240
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: ...
分类:
其他好文 时间:
2016-03-27 07:07:34
阅读次数:
133
什么是构造方法?
只要有一个对象实例化则就会调用构造方法。
在构造方法中要注意以下几点:
—构造方法的名称必须与类名一致
—构造方法的声明处不能有任何返回值类型的声明
—不能在构造方法中使用return返回一个值。
class Person{
public Person(){ // 声明构造方法
System.out.println("一个新的Person对象产生...
分类:
其他好文 时间:
2016-03-27 01:50:57
阅读次数:
190
我们要在Java中执行JavaScriptMethods.js中的execute(s1,s2)方法,JavaScriptMethods.js文件内容如下:function execute(s1, s2){
return s1 + s2;
}...
分类:
编程语言 时间:
2016-03-27 01:47:38
阅读次数:
148
def cumulative_distribution(distribution): """Return normalized cumulative distribution from discrete distribution."""#将离散分布转换成累积分布 cdf=[] #累积分布列表 cdf ...
分类:
其他好文 时间:
2016-03-26 21:54:41
阅读次数:
232
1.将数组A中的内容和数组B中的内容进行交换。(数组一样大)voidswap(int*a,int*b){ intten=0; ten=*a; *a=*b; *b=ten;}intmain(){ inttem=0; intarr1[4]={1,2,3,4}; intarr2[4]={5,6,7,8}; inti=0; for(i=0;i<sizeof(arr1)/sizeof(arr1[0]);i++) { swap(&arr1[i],&..
分类:
编程语言 时间:
2016-03-26 20:35:22
阅读次数:
261
Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must ...
分类:
其他好文 时间:
2016-03-26 18:46:28
阅读次数:
140