随笔分类 - C++
摘要: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...
阅读全文
摘要: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*...
阅读全文
摘要:1 #include <cassert> 2 #include <iostream> 3 4 using namespace std; 5 6 #define N 9 7 8 void print(const int* arr, int n); 9 10 void insert_sort (int* arr, int n, int (*cmp)(int, int)); 11 void bin_insert_sort (int* arr, int n, int (*cmp)(int, int)); 12 void shell_sort (int* arr, int n..
阅读全文
摘要: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...
阅读全文

浙公网安备 33010602011771号