摘要: 为了避免混淆,做如下规定,以下代码若不加特殊说明都运行于32位平台,结构体的默认对齐值是8,各数据类型所占字节数分别为char占一个字节int占四个字节double占八个字节。两个例子请问下面的结构体大小是多少?struct Test{ char c ; int i ;};这个呢?str... 阅读全文
posted @ 2015-07-03 09:07 朱传林 阅读(137) 评论(0) 推荐(0)
摘要: 1、sizeof是运算符,strlen是函数;2、sizeof可以用类型作为参数,而strlen只能用char*型量作为参数,且必须以‘\0’结尾; sizeof(int)=4;3、数组名作为sizeof的参数时,不会退化为指针,而作为函数的参数的时候会退化为指针; char a[10]="abc... 阅读全文
posted @ 2015-07-03 09:05 朱传林 阅读(112) 评论(0) 推荐(0)
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-07-03 07:58 朱传林 阅读(103) 评论(0) 推荐(0)
摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-07-03 07:55 朱传林 阅读(184) 评论(0) 推荐(0)