sizeof返回对象或类型名的长度,返回值类型为size_t,长度的单位是字节。 sizeof操作符在编译时已经得到了结果,即sizeof表达式的结果是编译时常量,字节对齐是编译时决定的。 字长:指明整数和指针数据的标称大小。 sizeof 计算栈中分配的大小,对于静态变量和全局变量都是存放在全局数 Read More
posted @ 2014-06-12 10:53 Xylophone Views(609) Comments(0) Diggs(0)
注意:整形数据,正数或者负数都可以,但atoi和itoa不适用于带小数点的数。(1)string“11”转换成整数11string str;int i = atoi(str.c_str());或者用字符指针:char *pStr;int i = atoi(pStr);(2)整数转换成字符指针:ito... Read More
posted @ 2014-06-12 10:25 Xylophone Views(395) Comments(0) Diggs(0)
常用以下ASCII:(1)十进制数0到9 (可以用此进行0到9之间的char和int的转换,记住超过9的数就不灵了:char a =0x31;cout<<a<<endl //输出1) 0 1 2 3 4........ 0x30 0x31 0x32 0x33 0x34...(2)字母... Read More
posted @ 2014-06-12 10:10 Xylophone Views(206) Comments(0) Diggs(0)
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?"Time Limit Exceeded"费时间的方法如下:查看p结点与它之前的结... Read More
posted @ 2014-06-12 09:20 Xylophone Views(142) Comments(0) Diggs(0)
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following req... Read More
posted @ 2014-06-10 16:34 Xylophone Views(181) Comments(0) Diggs(0)
Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime c... Read More
posted @ 2014-06-10 10:54 Xylophone Views(133) Comments(0) Diggs(0)
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complex... Read More
posted @ 2014-06-10 09:04 Xylophone Views(153) Comments(0) Diggs(0)
Given a binary tree, return the postorder traversal of its nodes' values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,... Read More
posted @ 2014-06-10 08:45 Xylophone Views(157) Comments(0) Diggs(0)
Given a binary tree, return the preorder traversal of its nodes' values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3... Read More
posted @ 2014-06-10 08:08 Xylophone Views(121) Comments(0) Diggs(0)
Sort a linked list using insertion sort.对于指针链表类题,分析时一定要用笔先清晰画出来,每个指针对应那些结点。对比:(1)插入排序的顺序表实现,是对temp从参考点temp往前与一个个元素比较,(2)插入排序的链表实现,是对temp从头结点开始往后与一个个元素... Read More
posted @ 2014-06-09 11:33 Xylophone Views(145) Comments(0) Diggs(0)