#pragma pack(4)typedef struct{ char buf[3]; word a;}kk;#pragma pack()对齐的原则是min(sizeof(word ),4)=2,因此是2字节对齐,而不是我们认为的4字节对齐。这里有三点很重要:1.每个成员分别按自己的方式对齐,并能最...
分类:
其他好文 时间:
2014-09-21 13:09:20
阅读次数:
217
1.指针是一个实体,而引用仅是个别名;2. 引用使用时无需解引用(*),指针需要解引用;3. 引用只能在定义时被初始化一次,之后不可变;指针可变;4. 引用没有 const,指针有 const;5. 引用不能为空,指针可以为空;6. “sizeof 引用”得到的是所指向的变量(对象)的大小,而“si...
分类:
其他好文 时间:
2014-09-20 23:51:49
阅读次数:
249
题目:1002 A Corrupt Mayor's Performance Art
题意:有一个长度 n 的序列,初始染色2,有两种操作,P x ,y ,z,区间x---y染色为z,另一种Q x,y,查询区间 x -- y 有几种颜色,并输出,注意会覆盖。
分析:跟POJ 2777一样,不过这个要输出颜色,所以线段树查询的时候顺便把路径存起来打印。代码:
AC代码:
#...
分类:
其他好文 时间:
2014-09-20 20:07:29
阅读次数:
333
sizeof(...)是运算符,而不是一个函数;strlen(...)是函数,要在运行时才能计算。
分类:
其他好文 时间:
2014-09-19 23:50:46
阅读次数:
204
TScrollInfo 结构体。在Delphi中定义在windows单元下。定义如下: tagSCROLLINFO = packed record cbSize: UINT; //结构体大小,在使用时首先要初始化 SizeOf(ScrollInfo) fMask: UIN...
分类:
其他好文 时间:
2014-09-19 23:44:36
阅读次数:
308
1.结构体对齐问题32位机器例子1:结果:例子2:struct A{ char c1; int i; short s; int j;}a;struct B{ int i; int j; short s; char c1;}b;结构A没有遵守字节对齐原则(为了区分,我将它叫做对齐声明原则),结构B遵守...
分类:
其他好文 时间:
2014-09-19 20:53:15
阅读次数:
212
转自:strcpy函数的实现代码实现#include #include #include //#include using namespace std;int strlen(const char *src){ assert(src != NULL); int lens = 0; w...
分类:
其他好文 时间:
2014-09-19 19:02:15
阅读次数:
169
1. 串赋值StrAssign/* 生成一个其值等于chars的串T */雅加达娱乐城Status StrAssign(String T,char *chars){ int i; if(strlen(chars)>MAXSIZE) return ERROR; else { T[0]=strlen.....
分类:
其他好文 时间:
2014-09-19 15:17:55
阅读次数:
226
这里的交叉链表,是Y型交叉链表。话不多说,上代码:首先定义一些用到的宏和链表节点,这里使用最简单的单向链表1 #define ARRAY_SIZE(a) sizeof((a)) / sizeof((a)[0])2 #define ABS(a) (a) > 0 ? (a) ...
分类:
其他好文 时间:
2014-09-19 11:56:55
阅读次数:
259
check here.Basically the compiler will insert unused memory into a structure so that data members are optimally aligned for better performance.
分类:
其他好文 时间:
2014-09-19 05:31:24
阅读次数:
270