1.解释实现多线程的几种方法?一 Java 线程可以实现 Runnable 接口或者继承 Thread
类来实现,当你打算多重继承时,优先选择实现 Runnable。2.Thread.start ()与 Thread.run
()有什么区别?Thread.start ()方法(native)启动线程...
分类:
编程语言 时间:
2014-05-23 08:37:33
阅读次数:
311
1.new、delete、malloc、free关系delete会调用对象的析构函数,和new对应free只会释放内存,new调用构造函数。malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。它们都可用于申请动态内存和释放内存。对于非内部数据类型的对象而言,光用...
分类:
编程语言 时间:
2014-05-23 08:32:21
阅读次数:
460
【题目】
Given an unsorted integer array, find the first missing positive integer.
For example,
Given [1,2,0] return 3,
and [3,4,-1,1] return 2.
Your algorithm should run in O(n) time and uses constant space.
【题意】
给定一个数组,找出第一个缺失的正数。时间复杂度O(n)
...
分类:
其他好文 时间:
2014-05-21 17:13:07
阅读次数:
219
【题目】
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
Each number in C may only be used once in the combination.
Note:
All numbers (including target) will be ...
分类:
其他好文 时间:
2014-05-21 15:55:25
阅读次数:
259
这一篇文章专门整理一下研究过的Android面试题,内容会随着学习不断的增加,如果答案有错误,希望大家可以指正
1.简述Activity的生命周期
当Activity开始启动的时候,首先调用onCreate(),onStart(),onResume()方法,此时Activity对用户来说,是可见的状态
当Activity从可见状态变为被Dialog遮挡的状态的时候,会调用on...
分类:
移动开发 时间:
2014-05-21 15:43:02
阅读次数:
333
问题:
求两个数的最大公约数
解法一:
欧几里得辗转相除法:
f(x,y) = GCD(x,y), 取k = x / y, b = x % y,则:x = k*y + b;
如果一个数能整除x,y,则它也能整除b,y; 而且能整除b,y的数必能整除x,y,即x,y和b,y的公约数是相同的,其最大公约数也是相同的,即f(x,y) = f(y ,x % y) (x>=y>0)...
分类:
其他好文 时间:
2014-05-21 09:28:26
阅读次数:
275
在Java语言中,当实例化对象时,对象所在类的所有成员变量首先要进行初始化,只有当所有类成员完成初始化后,才会调用对象所在类的构造函数创建对象。...
分类:
编程语言 时间:
2014-05-21 08:58:13
阅读次数:
303
【题目】
有很多无序的数,从中找出最大的K个数。假定他们都不相等。
【解法一】
如果数据不是很多,例如在几千个左右,我们可以排一下序,从中找出最大的K个数。排序可以选择快速排序或者堆排序
[cpp] view
plaincopy
#include
#include
int cmp(const void *a,const ...
分类:
其他好文 时间:
2014-05-21 07:30:07
阅读次数:
234
【题目】
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
For example,
Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.
The above elevation map is represente...
分类:
移动开发 时间:
2014-05-21 06:44:38
阅读次数:
359
大数相加
[cpp] view
plaincopy
#include
#include
char a[10001],b[10001],sum[10002];
int BigIntegerAdd(){
//两个数的长度
int lena = strlen(a);
int l...
分类:
其他好文 时间:
2014-05-21 06:32:32
阅读次数:
361