刚学python,学到了有关于类和对象的地方。对一个概念有点模糊,后来通过实践编码找到一定规律
在python中
class test(object):
id=2
name='tt' list=['tt','dd']
def change(self,newA,new_id):
self.id=new_id
self.age=new...
分类:
编程语言 时间:
2014-06-25 19:29:20
阅读次数:
267
【问题】
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, /.
Each operand may be an integer or another expression.
Some examples:
...
分类:
编程语言 时间:
2014-06-24 23:22:53
阅读次数:
331
//加入收藏
function AddFavorite(){
if (document.all) {
addToBookMark(window.location.href, document.title);
} else if (window.sidebar) {
addToBookMark(document.title, window.location.href);
}
}
func...
分类:
其他好文 时间:
2014-06-24 23:21:37
阅读次数:
200
C++中数组很坑,有没有类似Python中list的数据类型呢?类似的就是vector!vector 是同一种类型的对象的集合,每个对象都有一个对应的整数索引值。和 string 对象一样,标准库将负责管理与存储元素相关的内存。我们把 vector 称为容器,是因为它可以包含其他对象。一个容器中的所有对象都必须是同一种类型的。...
分类:
编程语言 时间:
2014-06-24 23:07:59
阅读次数:
310
凯莱公式:
spanning_trees_num( G ) = spanning_trees_num( G - e ) + spanning_trees_num( G · e )
矩阵树定理:
G 对应的拉普拉斯矩阵(度矩阵 - 邻接矩阵)L( G )
删除任意一行一列得到的行列式的值det( L*( G ) )
即生成树的个数,即spanning_trees_num( G...
分类:
其他好文 时间:
2014-06-24 22:05:54
阅读次数:
237
Python中一切皆是对象,每个对象都可以有多个属性。Python是如何管理这些属性呢?我们来探讨一下。
属性的__dict__系统
对象的属性包含两部分:类属性和对象属性。对象的属性可能来自于其类的定义,叫做类属性。类属性可能来自于类的定义自身,也可能来自父类。一个对象的属性还可能是该对象实例定义的,叫做对象属性。
对象的属性存储在对象的__dict__属性中。__dict__为一...
分类:
编程语言 时间:
2014-06-24 21:03:01
阅读次数:
218
【问题】
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
【代码】
class Solution:
# @param s, a string
# @retu...
分类:
其他好文 时间:
2014-06-24 21:00:30
阅读次数:
168
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplica...
分类:
其他好文 时间:
2014-06-24 20:58:32
阅读次数:
230
排序算法有不少,当然,一般的语言中都提供某个排序函数,比如Python中,对list进行排序,可以使用sorted(或者list.sort()),关于这方面的使用,在我的github代码库algorithm中有几个举例,有兴趣的看官可以去那里看看(顺便告知,我在Github中的账号是qiwsir,欢迎follow me)。但是,在某些情况下,语言中提供的排序方法或许不适合,必须选择某种排序算法。
...
分类:
其他好文 时间:
2014-06-24 18:33:33
阅读次数:
205
一:勘误
classifier类中: def fprob(self, f, cat):
if self.catcount(cat) == 0:
return 0
#notice: rember change int to double or float
# + 0.0 or *1.0 is ok, other wise, may get 0.
return self.fc...
分类:
其他好文 时间:
2014-06-24 17:49:42
阅读次数:
211