自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 字节跳动4面面筋

一面: 狂问项目–架构 快排 归并 让我10分钟后准备二面 二面: linux虚拟内存 给一个矩阵,一个坐标,这个坐标的点只能向比他小的格子(上下最有)移动,能不能到达边缘–dfs暴力搞定 让我明天准备3面 三面: 狂问项目–架构 从西安到北京有很多路线,找出最近的一条。–不会,后来查的是用动归 给一个数组,找出所有和为target的子数组–dfs硬搜 让我准备hr hr: 随便聊聊 问我对技术和测试哪个更感兴趣,我说技术,然后给我安排加了一面(进公司后才知道给我加了100块钱哈) 加面: rand3求ra

2021-05-02 17:53:56 2457 8

原创 git操作

1、本地初始化 git 设置 git config --global user.name “你的名字或昵称” git config --global user.email “你的邮箱” 2、进入项目文件夹,初始化目录 – 通过命令 git init 把这个目录变成git可以管理的仓库 git init 3、把文件添加到版本库中 – 通过命令 git add . / git add -A 添加到暂存区里面去,后面的小数点“.”和“-A”,意为添加文件夹下的所有文件,如需添加指定文件夹 git add 后面直接

2021-03-29 13:28:41 288

原创 linux下jsoncpp的使用

第一步: 首先安装jsoncpp库 我买的腾讯的云服务器,系统是centos7 下边为安装指令 yum install jsoncpp-devel 安装后,我们只需要在程序中包含头文件 #include<jsoncpp/json/json.h> 就可以使用jsoncpp提供的方法去读写json文件 下边是一些常间的例子 比如对于这个test.json文件内容 { “name” : “xiaohua”, “age” : 18, “sex” : “male” } 读取的方法为 test.cpp: #

2020-10-04 19:21:41 563

原创 csdn索引

电我头像即可查看我所有的csdn文档

2020-08-05 22:53:43 253

原创 牛客客似云来(大数算法)

#include #include #include #include #include using namespace std; //大数相加 string add(string& s1,string& s2) { string str1=s1; string str2=s2; //反转 reverse(str1.begin(),str1.end()); reverse(str2.begin(),str2.end()); int len=str1.size()>str2.size()

2020-08-04 23:21:32 267

原创 推箱子,带登录,带写入文件,带悔棋,无UI界面,大学c语言课程设计可用

#include<stdio.h> #include<string.h> #include<stdlib.h> #include<conio.h> #include<Windows.h> int arr[5][10][10] = // 5张地图 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 3, 0, 0, 0, 0, 3, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,

2020-07-31 19:30:48 493 1

原创 c++特殊类

#include #include using namespace std; //只能在堆上创建对象 //1.构造函数私有(防止在栈和数据段进行创建对象) //2.ban掉构造函数和赋值运算符 //3.提供创建对象的方法(必须为静态,否则类名+::掉不动) class HeapOnly { public: static HeapOnly* create() { return new HeapOnly; } private: HeapOnly() {} HeapOnly(const HeapOnly&am

2020-07-31 19:16:16 173

原创 哈希表的实现(线性探测,开散列,位图,布隆过滤器)

//线性探测,性能较差,一般不用 #include #include #include using namespace std; enum Status{ EXIST,DEL,EMPTY }; template<class K,class V> struct HashNode { pair<K,V>_val; Status _status; HashNode(const pair<K,V>& val=pair<K,V>()) :_val(val) ,_

2020-07-24 22:09:04 185

原创 线性探测哈希表

//哈希闭散列线性探测 #include #include #include using namespace std; enum Status { EXIST,DEL,EMPTY }; template <class K,class V> struct HashNode { pair<K, V>_val; Status _status; HashNode(const pair<K, V>& val = pair<K, V>()) :_val(val)

2020-07-22 20:55:40 261

原创 红黑树实现map和set

#pragma once #include #include using namespace std; enum Color { BLACK, RED }; template struct RBNode { V _val; Color color; RBNode* _left; RBNode* _right; RBNode* _parent; RBNode(const V& val = V()) :_val(val), color(RED), _left(nullptr), _right(null

2020-07-18 18:23:10 221

原创 扑克牌-->牛客最搞心态的题目

#include #include #include #include #include using namespace std; #define B_KING 200 #define S_KING 100 bool isDoubleKing(vector& arr) { return arr[0] == S_KING && arr[1] == B_KING; } bool isDouble(vector& arr) { return arr[0] == arr[1]; }

2020-07-16 15:05:44 148

原创 网易跳石板问题详解

基本思想:DP算法 首先创建一个最大值+1那么大的数组表示每一个石板,之所以是最大值+1的原因是要取下标为最大值的石板 然后遍历每个石板,把每个石板的约数都保存起来,然后取到从这个石板过去的最小值(即最优解) 然后取最大值对应的那个石板返回就OK DP算法的核心思维其实就是每一步取最优解,它也是一种分治思想的深刻体现 #include #include #include using namespace std; void GainStep(int n, vector& arr) { //for (i

2020-07-13 13:50:17 242

原创 AVL树

AVL树的各种变换图 //AVL 树 #include #include #include using namespace std; template struct TreeNode { T _val; TreeNode* _left; TreeNode* _right; int bf; TreeNode* _parent; TreeNode(const T& val = T()) :_val(val), _left(nullptr), _right(nullptr),bf(0),_parent(

2020-07-12 15:59:40 119

原创 用管道写的ls-l

#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<fcntl.h> int main() { int fds[2]; int ret=pipe(fds); if(ret==-1) perror(“fds”),exit(0); pid_t pid=fork(); if(pid0) { dup2(fds[1],1); execlp(“ls”,“ls”,"-l",NULL); exit(

2020-07-07 14:09:34 767 1

原创 set的基本接口以及基本性质,基本接口测试

1.创建 set<typename, compare>对象名字按照compare的方式来决定输出排序方式 ,如果第二个参数不写,缺省是从小到大 2.迭代器 begin()返回一个指向当前容器开始位置的只读迭代器 end()返回一个指向当前容器末尾位置的只读迭代器 rbegin()返回一个指向当前容器开始末尾的只读迭代器 rend()返回一个指向当前容器开始位置的只读迭代器 cbegin()返回一个指向当前容器开始位置的只读迭代器 cend()返回一个指向当前容器末尾位置的只读迭代器 rcbegi

2020-07-06 11:23:55 200

原创 linux线程处理函数封装

#include #include<time.h> #include<pthread.h> using namespace std; namespace DongGe { class thread{ typedef void*(func)(void); public: //构造函数 thread(func run,void* p) { pthread_create(&tid,NULL,run,p); } thread(func run) { pthread_create(&a

2020-07-05 20:57:34 234

原创 线程池

头文件: pthread.h #pragma once #include<pthread.h> struct task{ void*(run)(void arg); //任务执行回调函数 void* arg; //回调函数的参数 struct task* next; //指向下一个任务节点的指针 }; typedef struct task task_t; struct thread_pool { pthread_mutex_t mutex; //线程锁 pthread_cond_t con

2020-07-05 17:10:13 125

原创 完全二叉树

#include #include using namespace std; template struct BTNode { T _val; BTNode* _left; BTNode* _right; BTNode(const T& val = T()) :_val(val), _left(nullptr), _right(nullptr) { } }; template class BSTree { public: typedef BTNode Node; public: Node* find

2020-07-04 14:16:46 114

原创 list类的基本实现和常用的接口

#include using namespace std; template class ListNode { public: ListNode(const T& val = T()) :_val(val), _next(nullptr), _prev(nullptr) {} T _val; ListNode* _next; ListNode* _prev; }; //迭代器类 template<class T, class Ref, class Ptr> class ListIter

2020-06-15 16:41:44 238

原创 vector的简单实现

#include #include using namespace std; template class Vector { public: Vector() :_start(nullptr) , _finish(nullptr) , _eos(nullptr) {} size_t size() const { return _finish - _start; } size_t capacity() const { return _eos - _start; } void pushBack(c

2020-06-13 16:23:15 229

原创 模板

(一) 泛型编程的概念 首先看一个栗子 int add(int a,int b) { return a+b; } double add(double a,double b) { return a+b; } short add(double a,double b) { return a+b; } 要完成不同参数类行的add计算,显然,我们可以用重载来完成这个事情,但是重载仍然是存在缺点的,我们可以看出它的代码量是极为巨大的,这大大...

2020-06-11 22:22:59 148

原创 string类实现和测试

#include #include using namespace std; namespace bit { class string { friend ostream& operator<<(ostream& _cout, const bit::string& s); friend istream& operator>>(istream& _cin, bit::string& s); public: typedef char* ite

2020-06-11 14:21:59 279

原创 用户和权限

首先先说用户的概念 用户分为管理员用户和普通用户 这一点非常容易去区分 如果你是root那么你就是管理员用户 ifnot你就不是 现在我们步入正题 1.创建用户 useradd 你创建用户的名字 比如 useradd mmc 这样就创建了mmc这个用户 这时候你cd /home 就会发现这个目录先下多了一个mmc这个目录 你cd进去然后ls -a就可以看到该用户的配置信息 这时候你在打开/etc/passwd这个文件就可以发现这个文件增加了一条记录 这时候你在打开/etc/shadow这个文件也可以发现这个

2020-06-02 00:00:43 270

原创 linux之基本命令的使用

1.ls命令 作用:显示当前目录下边的文件 ls -a显示所有文件,包括.开头的不可见文件 ls -l 显示文件的详细信息: 权限 时间 ls -i显示文件的inode信息 ls -t将文件按照时间顺序显示 ls -R 递归的显示文件信息 当然还有很多,这里写的都是最常用的 2.pwd 作用:显示用户当前所在的目录 3.cd 作用:改变工作路径 cd 后加指定路径,跳到指定路径,如果什么都不跟,则回到家目录 举几个栗子 cd /root/xxx 跳到/root/xxx目录下 cd …返回上一级 cd .跳

2020-06-01 22:59:50 197

原创 mciSendString函数播放mp3音乐,这里直接给大家上代码

//看了网上很多人写了一大堆的mciSendString音乐播放函数理论的介绍,非常的乏味,主要是还不一定播放的出来,所以这里就不说理论了,先上coding #include #include<windows.h> #include<mmsystem.h> #pragma comment(lib,“winmm.lib”) void test() { mciSendString(TEXT(“open D:/music//msc.mp3”), NULL, NULL, NULL);//打

2020-06-01 13:06:03 5887 4

原创 C++之动态内存管理

想必很多学习C++的人都有很深厚的C语言基础. 在C语言中,我们是用malloc,calloc,realloc三位男士和free一位女士来动态管理内存的 先coding一下C语言的基本动态内存管理模式 void RAMManageByC() { int ptr1=(int)malloc(sizeof(int));//申请大小为sizeof(int)大小的内存,不进行初始化 int* ptr2=(int*)malloc(sizeof(int)n);//申请长度为n的整形数组,不进行初始化 int ptr3=(

2020-05-31 23:20:23 145

原创 面向对象(OOP)思想3

1.再谈构造函数 在我前面写的博客面向对象(OOP)思想2中,我介绍了基本构造函数的使用 但是值得注意的是前面所使用的构造函数实际上并不是对对象进行初始化,而是简单的赋值 Date(int year,int month,int day) { _year=year;//赋值操作 _month=month; _day=day; } 事实上,C++有对对象的初始化语法,话不多说,先上代码 Date(int year,int month,int day) :_year(year), _month(month), _

2020-05-30 14:31:00 121

原创 自治日历

#include #include using namespace std; class Date{ public: Date() { cout<<"请输入你要查找的日期(年月日中间空格隔开,比如: 2020 5 21): "; string s; getline(cin,s); stringstream ss; ss<<s; int year,month,day; ss>>year>>month>>day; if(year<1902||mo

2020-05-26 14:38:26 140

原创 面向对象(OOP)思想和类(2)

(一)类的6个默认成员函数 1.构造函数 1.用处:用于初始化类的成员 语法 class Date{ Date() {} }; 事实上这就完成了一个简单的构造函数,也就是传说中的无参构造 当创建Date类型的对象时候,编译器会自动调用构造函数,并且在整个对象的生命周期内只会调用一次 当然构造函数也有许多自己的特性,我在这里罗列一下 需要注意的是:构造函数并没有创造对象,只是完成对创建出来对象的初始化 构造函数的特性: (1) 函数名与类名相同 (2)无返回值 (3)当对象实例化时编译器自动调用对应的构造函数

2020-05-25 20:47:40 229

原创 实现日期类

#include using namespace std; class Date { public: // 获取某年某月的天数 int GetMonthDay(int year, int month) { int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) arr[2] = 29;

2020-05-25 14:45:23 287

原创 面向对象(OOP)和类

1.面向对象 As is we all known C是面向过程的 然而它的进化版C++是面向对象的 面向对象是怎么搞的呢 事实上,面向对象其实很简单 它比较现实 比如一个人是由很多零件来组成的 对于面向过程的语言来说 关注的它的胳膊,它的腿,要完成一个动作,就要让胳膊干啥,腿干啥 然而对于面向对象来说,它习惯于直接面向这个人,所关注的这个人的啥,而至于底层怎么实现,并不关注 2.然后我们说类(class) 类其实和C语言中的结构体有点类似,但有不一样 类可以定义函数(事实上在C++中结构体struct 仍

2020-05-24 15:26:11 306

原创 c++入门操作

1.命名空间(namespace) 概念上:创造一个命名空间就相当于创建了一个区域,这个区域里边定义的变量或者函数只能在这个区域里边使用 使用 命名空间的使用用文字描述实在是难以让人理解,我举个例子,一看就懂: namespace A{ int a; int b; int add(int a.int b) { return a+b; } } 这样子就创建了一个命名空间,名字是A 使用方法 比如这里要使用add完成1+2加法操作 必须是A::add(1,2) 当然也可以用using A::int add(in

2020-05-24 14:31:07 264

原创 排序

void Swap(int* arr,int left, int right) { int tmp = arr[left]; arr[left] = arr[right]; arr[right] = tmp; } void InsertSort(int* a, int n) { int tmp; int j; for (int i = 1; i < n; ++i) { tmp = a[i]; for (j = i; j >= 1 && a[j - 1] > tmp; --j

2020-05-13 13:24:24 143

原创 括号匹配

#include #include using namespace std; bool isRight(char* str) { if(strNULL) return false; stacksk; while(*str) { if(!sk.empty()) { if(*str’)’&&sk.top()’(’) { sk.pop(); } else if(*str’}’&...

2020-05-02 14:43:06 392

原创 Burymine

#include<stdio.h> int stepNum(char arr[][10],int x,int y,int maxrow,int maxcol) { if(arr[x][y]!=’.’) return 0; int i=x; int j=y; int sum=0; while(i<maxrow&&arr[i][y]!=’#’) { if(arr[i]...

2020-05-02 14:26:55 160

原创 c语言实现能量条小程序

#include<stdio.h> #include<stdlib.h> #include<memory.h> #include<unistd.h> int main() { char bu...

2020-04-30 15:39:42 234

原创 二叉树的一系列操作

BTNode* BinaryTreeCreate(BTDataType* a, int n, int* pi) { if (a[pi] != ‘#’) { BTNode root=(BTNode*)malloc(sizeof(BTNode)); root->_data = a[*pi]; ++(*pi); root->_left=BinaryTreeCreate(a,n,pi); +...

2020-04-29 13:57:15 156

原创 heap_sort

#include<stdio.h> #include<stdlib.h> void Swap(int* arr, int left, int right) { int tmp = arr[left]; arr[left] = arr[right]; arr[right] = tmp; } void shiftDown(int* arr, int parent,int siz...

2020-04-18 23:58:42 97

原创 单链表

单链表 SingleList.h #pragma once typedef int Type; typedef struct Node { Node* next; Type val; }Node; typedef struct List { Node* head; }List; Node* CreatNode(Type val); void ListInit(List* list); void L...

2020-04-07 17:53:09 133

原创 双向链表

//DoubleList.h #pragma once typedef int Type; typedef struct Node { struct Node* next; Type val; struct Node* pre; }Node; typedef struct List { struct Node* header; }; Node* CreateNode(Type val); voi...

2020-04-07 16:37:26 93

空空如也

空空如也

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

TA关注的人

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