
C/C++
文章平均质量分 84
leonharddt
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++奇技淫巧(一):取位数,交换,比较,求均值
一、计算一个数转化成二进制后包含1的位数 写法:判断x&(x-1)计算了几次 程序: int func(int x) { int count = 0; while(x){ count++; x = x&(x - 1); } return count; } 牛逼!!! ———————————————— 二、编程风格原创 2017-07-15 14:58:14 · 17310 阅读 · 0 评论 -
面试编程知识+算法题总结(一)
一、C++中引用和指针的区别1. 指针是一个变量,存储的是一个地址,指向内存的一个存储单元;而引用跟原变量本质是一样的,只不过是原变量的一个别名2. 指针可以为const;引用不可为const3. 指针可以为多级;引用不可为多级;4. 指针可以为空;引用不可为空,并且定义的时候必须初始化5. 指针在初始化后可以改变;引用在初始化后不可改变6. sizeof引用得到的是对象的大小;而sizeof指针...原创 2017-07-19 14:19:34 · 317 阅读 · 0 评论 -
C++ 自己动手写排序
全部给我死记硬背住!!! 一、插入排序 void InsertSort(int *arr, int arrLen) { for (int i = 1; i < arrLen; i++) { int tmp = arr[i]; int j = 0; for (j = i; j > 0 && tmp < arr[j-1]; j--)原创 2017-11-12 16:22:19 · 406 阅读 · 0 评论 -
[Easy]C++ 第二期 7道
104. Maximum Depth of Binary Tree 二叉树最大深度 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthes原创 2017-11-22 21:04:21 · 295 阅读 · 0 评论 -
[Easy]C++ 第一期 6道
400. Nth Digit正整数列的第n位数Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n < 231...原创 2017-07-12 14:08:25 · 349 阅读 · 0 评论