自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 收藏
  • 关注

原创 Nginx源码学习-内存池

Nginx源码学习-内存池Nginx源码学习-内存池内存池内存池-数据结构定义Nginx源码学习-内存池内存池一般情况下,在内存分配中,我们使用malloc和free分配内存(c++领域中采用了new和delete,具体区别请自行百度),但是存在着以下弊端:频繁使用malloc和free,会导致内存碎片,系统直接回收内存不方便。典型的例子就是大并发频繁分配和回收内存,会导致进程的内存产生...

2019-01-30 20:02:45 156

原创 微软编程100-012

第12题 题目:求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字 以及条件判断语句(A?B:C)#include<iostream>using namespace std;class tmp{public: tmp() { n++; m += n; } static

2017-07-18 17:31:01 260

原创 微软100题-010反转字符串

翻转句子中单词的顺序。 题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。 句子中单词以空格符隔开。为简单起见,标点符号和普通字母一样处理。 例如输入“I am a student.”,则输出“student. a am I”。#include<iostream>#include<algorithm>#include<cctype>#include<string>u

2017-07-18 16:57:07 228

原创 微软100题-009

第9题(树) 判断整数序列是不是二元查找树的后序遍历结果 题目:输入一个整数数组,判断该数组是不是某二元查找树的后序遍历的结果。 如果是返回true,否则返回false。 例如输入5、7、6、9、11、10、8,由于这一整数序列是如下树的后序遍历结果: 8 / / 6 10 / / / / 5 7 9 11 因此

2017-07-18 16:45:47 192

原创 牛克编程-二分查找

题目描述 对于一个有序数组,我们通常采用二分查找的方式来定位某一元素,请编写二分查找的算法,在数组中查找指定元素。 给定一个整数数组A及它的大小n,同时给定要查找的元素val,请返回它在数组中的位置(从0开始),若不存在该元素,返回-1。若该元素出现多次,请返回第一次出现的位置。 测试样例: [1,3,5,7,9],5,3 返回:1#include<iostream>#include<v

2017-07-17 16:53:13 226

原创 牛克编程-寻找coder

请设计一个高效算法,再给定的字符串数组中,找到包含”Coder”的字符串(不区分大小写),并将其作为一个新的数组返回。结果字符串的顺序按照”Coder”出现的次数递减排列,若两个串中”Coder”出现的次数相同,则保持他们在原数组中的位置关系。 给定一个字符串数组A和它的大小n,请返回结果数组。保证原数组大小小于等于300,其中每个串的长度小于等于200。同时保证一定存在包含coder的字符串。

2017-07-17 16:04:59 274

原创 微软100题--004

//1 在二元树中找出和为某一值的所有路径#include<iostream>#include<vector>using namespace std;struct BSTreeNode{ int m_nValue; // value of node BSTreeNode *m_pLeft; // left child of node BSTreeNode *m_pRi

2017-07-14 19:43:12 258

原创 微软面试100题--001

//1.把二元查找树转变成排序的双向链表//题目://输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。//要求不能创建任何新的结点,只调整指针的指向。//// 10// / /// 6 14// / / / /// 4

2017-07-14 15:58:00 299

原创 寻找和为定值的两个数-三种解法

#include<iostream>#include<vector>#include<assert.h>using namespace std;int main2017713(void)//解法1 时间复杂度 n*n{ int a[] = { 1, 2, 4, 7, 11, 15,2,4,8,10,6,1,8,3,4,5,6,7,8,9,10 }, n = sizeof(a) /

2017-07-13 13:47:40 247

原创 虚函数与构造函数、析构函数

虚函数是多态的基础 (PS多态是一个接口多个实现) 多态条件:1.继承 2. 虚函数 3. 父类指针指向子类#include<iostream>using namespace std;class myclass{public: virtual void go() { cout << "myclass" << endl; } virtual

2017-07-11 21:11:56 259

原创 0711华为机试-名字的漂亮度

坑爹的机试题,题很容易,线下通过,线上调试了很久,最后还是通过了#include<iostream>#include<vector>#include<string>#include<cctype>#include<algorithm>using namespace std;int main(){ int n; string str; while (cin>>n)

2017-07-11 17:21:11 244

原创 0711编程之美找符合条件的整数

#include<iostream>#include<queue>using namespace std;int x(int n,int m){ int temp = n*m; while (temp) { if (temp % 10 >= 2) return 0; temp=temp/10; }

2017-07-11 15:45:04 218

原创 0710 编程之美之N!末尾0的个数

#include<iostream>using namespace std;int main_()//解法1{ int n; while (cin >> n) { int count = 0; for (int i = 1; i <= n; ++i) { int j = i;

2017-07-11 11:08:10 190

原创 c++ 重载为返回值对象以及引用的情况

#define _CRT_SECURE_NO_WARNINGS#include#includeusing namespace std;class mystring{public:char *p;int n;mystring() :p(nullptr), n(0){}mystring(char *p){this->n = strlen(

2017-07-10 16:54:56 365

原创 0710编程之美二进制扩展问题

#includeusing namespace std;int main(){int a, b;while (cin >> a >> b){int count = 0;int c = a^b;while (c){c &= c - 1;count++;}cout }cin.get();return 0;}

2017-07-10 13:30:23 297

原创 0710编程之美二进制树中1的个数 三种解法

#includeusing namespace std;int main7101()//解法1{int a;while (cin >> a){int count = 0;while (a){if (a % 2 == 1)count++;a = a / 2;}cout }cin.get();return 0;}int mai

2017-07-10 12:44:10 214

原创 0710C++基本数据类型之间的转换

#includeusing namespace std;int main(){int a = 1.2;//自动转换int b = static_cast(1.6);//显示转换int c = (int)2.5;//C风格int *ptr1 = nullptr;char *ptr2 =reinterpret_cast(ptr1);//CPP风格const in

2017-07-10 00:45:58 179

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除