第一次见到这个题目,我觉得自己没学到java,太浅了,其实这个问题没有考synchronized关键字,只是考什么是对象?1.在java编程思想的第二章有一句话;一切都是对象,很可惜int,char 等不是的,虽然他们有他们的包装类,但是java还是保留了int 这些好用的原子类型,对于synchr...
分类:
编程语言 时间:
2014-07-06 17:04:51
阅读次数:
409
逆波兰式的求解,建立一个类栈容器,遍历给定的逆波兰表达式,遇到数字就push, 遇到操作符就进行出栈,连续出两次,因为给定的四则运算符都是双目的,这里注意下这两个操作数的先后顺序,因为对于加法和乘法没关系,但是对于减法和除法是有先后关系的。然后进行相应的运算,将结果push进栈中。
这里附带说明下python中进行除法运算与c,java系列中的除法的不同,就是向下取整的问题。这种不同表现在两个操...
分类:
编程语言 时间:
2014-07-06 12:22:02
阅读次数:
235
作者:iamlaosong
1、问题提出
编程中发现一个问题,系统总是提示编译错误,ByRef 参数类型不符,
可实际上参数定义没问题,原因在哪儿呢?
2、问题环境
假定函数定义如下:
Function get_kind(addr As String) As Integer
......
End Function
调用过程:
Sub check_addres...
分类:
其他好文 时间:
2014-07-06 10:45:44
阅读次数:
399
可以练习下链表的逆置。
def PrintListReversingly(head):
if head == None:
return
if head:
PrintListReversingly(head.next)
print head.val
def reverse(head):
if head == None or head.next == None:
return...
分类:
其他好文 时间:
2014-07-06 09:29:57
阅读次数:
214
;; Fermat's Little Theorem:
;; If N is a prime number and A is any positive integer less
;; than N, then A raised to the N-th power is congruent to A modulo N
;; Two numbers are said to be congruent...
分类:
其他好文 时间:
2014-07-06 09:05:22
阅读次数:
158
陆陆续续几个月下来,终于把题刷完了,过程中遇到的python的题解很少,这里重新用python实现下,所以题解可能都是总结性的,或者是新的心得,不会仅针对题目本身说的太详细。
def reverseWords(self, s):
s = ' '.join(s.split()[::-1])
return s
[ : : -1 ] 是将元素进行翻转...
分类:
编程语言 时间:
2014-07-06 00:37:50
阅读次数:
299
表达式: ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6
题目大意:给定一个逆波兰表达式,求该表达式的值
思路:由于逆波兰表达式本身不需要括号来限制哪个运算该先进行,因此可以直接利用栈来模拟计算:遇到操作数直接压栈,碰到操作符直接取栈顶的2...
分类:
编程语言 时间:
2014-07-06 00:07:22
阅读次数:
296
Determine whether an integer is a palindrome. Do this without extra space.
Some
hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string...
分类:
其他好文 时间:
2014-07-05 10:44:29
阅读次数:
227
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the sequence of...
分类:
其他好文 时间:
2014-07-04 07:35:58
阅读次数:
215
Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o...
分类:
其他好文 时间:
2014-07-03 23:51:47
阅读次数:
408