1、最后的笑声:
System.out.println('H' + "a");
System.out.println('H' + 'a');
结果:Ha169
这里需要注意到的是“+”运算符
在java里,参与“+”运算的两个操作数会被先提升到int型,然后运算。因此先'H'+'a'相当于 (int)('H'+'a')。
类似的:
short x = 1;
short y = 1;...
分类:
其他好文 时间:
2015-04-14 08:31:33
阅读次数:
120
一、何谓字节对齐?
现代计算机中内存空间都是按照字节(byte)划分的,从理论上讲,似乎对任何类型变量的访问都可以从任何地址开始,但实际情况是在访问特定变量的时候,经常在特定的内存地址访问,而不是顺序的一个接一个的排放。为了使CPU能够对变量进行快速访问,变量的起始地址应该具有某些特性,即所谓的“字节对齐”。比如4字节的int型,其起始地址应该位于4字节的边界上,即起始地址能够被4整...
分类:
编程语言 时间:
2015-04-14 08:29:40
阅读次数:
209
主要是思想,坐标和值什么的容易搞混public class Solution { public int firstMissingPositive(int[] A) { for(int i=0; i0 && A[i]<=A.length && A[i] != A[A[i]-1] )...
分类:
其他好文 时间:
2015-04-14 08:28:56
阅读次数:
121
要点单链表的结构可表示如下: typedef int ElemType; typedef struct LNode { ElemType data; ...
分类:
编程语言 时间:
2015-04-14 08:28:01
阅读次数:
150
比较典型的helper的题目,现在我还搞不太清楚dfs之类的,只能用helper来统称了,你明白那个调调就行public class Solution { public ArrayList> combinationSum(int[] candidates, int target) { ...
分类:
其他好文 时间:
2015-04-14 08:25:42
阅读次数:
125
public class Solution { public int[] searchRange(int[] A, int target) { int[] res = {-1, -1}; if(A==null || A.length<1) return res; ...
分类:
其他好文 时间:
2015-04-14 07:19:08
阅读次数:
174
二分,多设立一个返回条件变可以继承二分法ublic class Solution { public int searchInsert(int[] A, int target) { int l = 0, r = A.length-1; while(lt...
分类:
其他好文 时间:
2015-04-14 07:17:46
阅读次数:
159
思路:当遇到一个结点是返回1,当左右子树都返回1的时候,即最小公共父节点。//二叉树的数据结构
typedef struct MyStruct
{
char data;
struct MyStruct *leftChild;
struct MyStruct *rightChild;
}Node, *Tree;
//查找方法
int findFirstFather(Tree r...
分类:
其他好文 时间:
2015-04-14 02:02:27
阅读次数:
165
namespace 函数数组排序带出最大最小值及平均值{ class Program { static void Main(string[] args) { int[] b=new int[]{9,1,5,3,7}; int max = 0; //设置两个变量用来接收最低值与最小值。 int mi....
分类:
编程语言 时间:
2015-04-14 01:56:57
阅读次数:
143
#include
#define STRLEN 100
char *mystrcat(char *dest,const char *src)
{
char *ret = dest;
while(*dest != '\0')
{
dest++;
}
while(*dest++ = *src++)
{
;
}
return ret;
}
int main()
{
char ...
分类:
其他好文 时间:
2015-04-14 00:48:13
阅读次数:
195