- 博客(15)
- 收藏
- 关注
原创 二叉树
对于二叉树,树的高度和深度相等,对于某个节点来说就不一样了。struct Node{ int val; Node* left; Node* right;};int findHeight(Node* root){ if(root == NULL) return -1; return max(findHeight(ro...
2018-09-24 16:33:35 241
原创 strlen的结束条件
#include <stdio.h>#include<string.h>int main(){ char a[1000]; int i; for(i = 0; i < 1000; ++i){ a[i] = -1 - i; } char c[] = {1,1,0,2}; char d[] = {1,1,1,'\0',2}; char e[] = ...
2018-09-24 10:16:03 1089
原创 atof
简单的解析double字符串:考虑的情况:符号位 空格 异常输入(未考虑) 科学计数法(e,E)(未考虑)#include <iostream>#include <cmath>using namespace std;double atof_my(char* pStr){ //跳过空格 while(isspace(*pStr)) ++pS...
2018-09-22 20:13:39 646
原创 找异数(小米在线笔试)
输入:16#7B10#1234#13238#16END输出:8#16 #号之前是进制数(2~16),之后为该进制数下的数值,找出输入当中不同与其他数的数值。下例当中前三个表示123,最后一个表示14,所以输出8#16。代码的编译环境为vs2017 #include <iostream>#include <string>#includ...
2018-09-22 15:32:07 673 1
原创 比较两个字符数组和两个指针
#include<iostream>using namespace std;int main(){ char a[] = "hello"; char b[] = "hello"; char* c = "hello"; char* d = "hello"; //输出unequal if(a == b) cout<<"equal&quo
2018-09-21 22:18:23 581
原创 数组蓄水池
#include <iostream>#include <vector>using namespace std;int vol(vector<int> vec){ int max = vec[0]; int max_pos = 0; for(int i = 0; i < vec.size(); i++){ if(vec[i] >...
2018-09-20 21:08:08 351
原创 打开/关闭位的操作
#include <stdio.h>#include<math.h>/* 当flag为1时把第n位的0变为1 *//* 当flag为0时把第n位的1变为0 *//* 假设n从右侧开始,最右边第一位是1 */void setBit(unsigned* pData, unsigned n, unsigned flag){ unsigned m; if(flag...
2018-09-20 18:37:26 511
原创 字符排列组合
排列A(n,n)#include <iostream>#include<string>#include <vector>using namespace std;/* begin为开始的位置0 *//* res存放所有的排列方式 */void permutation(string& str_orgin, int begin, vec...
2018-09-20 09:42:25 261
原创 sizeof 指针和数组
#include <iostream>#include<cstring>using namespace std;int main(){ char** a[3][4];//一个指针占4个字节,数组存放的是指针类型char**/int** int** a1[3][4]; char* b[3];//指针数组 int* b1[3]; ...
2018-09-16 10:41:05 234
原创 百度在线笔试
1.#include <iostream>using namespace std;#define check1(x) x*x;inline int check2(int x){ int d; d = x * x; return d;}int main(){ cout<<check2(2 + 3)<<" "; cou...
2018-09-15 12:18:21 1313
原创 CVTE在线笔试
一、每一次排序之后都能确定至少一个元素位置的排序方法包括:1.选择排序:每次将最大的数放到最后。所以最大的数排一次序后位置就确定了。2.冒泡排序:同选择排序。每一次排序最大的值位置确定。3.快排:每一次排序pivot的位置确定。4.堆排序:每一次排序时,都是将堆顶的元素和最后一个节点互换,然后调整堆,再将堆大小减1。所以每一次排序堆顶元素确定。 不能至少确定一个元素的位置...
2018-09-11 21:16:27 6509
原创 free()多次的3种情况
#include<iostream>int main(){ char* name = NULL; free(name); free(name); free(name); system("pause"); return 0;}//正常运行 #include<iostream>int main(){ char* name ...
2018-09-10 21:35:41 2150 1
原创 装箱问题(中兴笔试)
给定有n个物体,用数组表示各个物体的大小,箱子容量为capacity,最少用多少个箱子把这n个物体装下方法1: #include <iostream>using namespace std;int minContainer(int len, int capacity, int arr[]) { struct BNode { int remain; BNo...
2018-09-09 20:20:21 714
原创 最大不重复子串(字节跳动笔试)
输入:abcc 输出:3 输入:baddabce 输出: 5#include<iostream>#include<string>#include<vector>using namespace std;int main() { string str; getline(cin, str); int count = 0; int max ...
2018-09-09 17:36:01 895 2
原创 Sep.5 2018 intel 笔试记录
1.GFM (Github Flavored Markdown) github上写 README.md文件的语言2.salting password3.linux chmod命令 rwx- r = 4,w = 2, x = 1,- 代表04.cd - 等价于 cd ..即当前目录的上一级目录5.gcc –E hello.c –o hello.i 选项”-o”是指目标文件,”.i...
2018-09-07 17:46:16 1254
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人