摘要: 1 #include 2 3 int main(void) 4 { 5 const int a = 10; 6 int* p = (int*)&a; 7 *p = 20; 8 std::cout << a << "|" << &a << std::endl; 9... 阅读全文
posted @ 2016-01-17 22:08 Astone 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 4 struct node { 5 int value; 6 node* next; 7 }; 8 9 void Insert(node*& head, int data)10 {11 node*... 阅读全文
posted @ 2013-10-27 11:01 Astone 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 problem: 输入一个以按升序排列的数组, 和一个数字 3 demand: 在数组中查找两个数, 使得他们的和正好是输入的那个数字, 要求 O(n) 时间复杂度. 如果有多对, 输出一对即可. 4 eg. 1 2 4 7 11 15 输入数字 15, 输出 4 11 5 */ 6 7 #include <iostream> 8 using namespace std; 9 10 void find2Number(int arr[], int n, int dest);11 12 #define N 613 14 int main(void)15 {16 int a 阅读全文
posted @ 2013-05-26 16:35 Astone 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 const 总是向右结合 3 eg, 4 当和 * 结合的时候表明: 变量的值作为一个地址, 而这个地址所指向的内容是常量. 5 当和变量名结合的时候, 表明这个变量本身的值是一个常量. (如果这个变量是一个指针, 那么变量本身的值是一个地址, 这个地址所指向的内容不一定是常量) 6 (const 和类型结合没有意义) 7 */ 8 #include <iostream> 9 10 using namespace std;11 12 int main(void)13 {14 int i = 0;15 const* int a = &i; // warn... 阅读全文
posted @ 2013-05-03 12:34 Astone 阅读(283) 评论(0) 推荐(0) 编辑