publicstaticStringbytes2HexString(byte[]b){Stringret="";for(inti=0;i<b.length;i++){Stringhex=Integer.toHexString(b[i]&0xFF);if(hex.length()==1){hex='0...
分类:
编程语言 时间:
2015-07-30 18:42:04
阅读次数:
121
python内部提供了很多内建函数。下面让我们从a-z开始学习python的内建函数 1.1 id(object) 返回对象的id(身份),返回的这个是一个整数(integer)是唯一的,在这个对象的整个生命周期内这个id都是唯一的 就是说两个不...
分类:
编程语言 时间:
2015-07-30 15:15:37
阅读次数:
141
python内部提供了很多内建函数。下面让我们从a-z开始学习python的内建函数
1.1
id(object)
返回对象的id(身份),返回的这个是一个整数(integer)是唯一的,在这个对象的整个生命周期内这个id都是唯一的
就是说两个不同是存在的两个数是可以有相同的id的。这是对象在内存中的地址。
一个实例:
a = 0
print(id(a))
输出的结果是:
...
分类:
编程语言 时间:
2015-07-30 15:01:10
阅读次数:
129
题目Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:
Given n = 13,
Return 6, because digit 1 occurred in the following n...
分类:
其他好文 时间:
2015-07-30 13:33:17
阅读次数:
141
平时使用中,进制转换只要使用基本数据类型对应的包装类Integer中的方法即可完成。 但其实我们也能用自己的方法去实现,下面例子使用了查表形式的方法来完成的进制的转换。
分类:
编程语言 时间:
2015-07-30 13:12:13
阅读次数:
212
// 字符串转换成16进制
public static String toHexString(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = (int) s.charAt(i);
String s4 = Integer.toHexString(ch);
str =...
分类:
其他好文 时间:
2015-07-30 00:52:33
阅读次数:
174
题目:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit...
分类:
其他好文 时间:
2015-07-30 00:28:50
阅读次数:
137
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"]. 1 class ...
分类:
其他好文 时间:
2015-07-30 00:26:45
阅读次数:
160
题目:Given an integer, write a function to determine if it is a power of two.解题思路:如果是power of two, 则2进制表达中,有且仅有一个1. 可以通过移位来数1的个数, 这里用了一个巧妙的办法, 即判断 N & (...
分类:
其他好文 时间:
2015-07-30 00:20:23
阅读次数:
103
题目:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), retu...
分类:
其他好文 时间:
2015-07-30 00:18:26
阅读次数:
203