- 博客(34)
- 收藏
- 关注
原创 根据权重获取值,权重随机(C++)
#include <iostream>#include <vector>#include <stdlib.h>#include <time.h> #include <cstdlib>#include <map>#include <vector>std::vector<int> randomByWeight(std::map<int, int> _mapWeight, int _coun
2021-08-11 15:52:10 687
原创 复杂链表复制
第一步复制节点, 先不然random节点class Solution {public: RandomListNode* Clone(RandomListNode* pHead) { // step 1 RandomListNode* temp = phead; while (temp) { RandomListNode* node = new Ran...
2020-03-30 18:04:36 118
原创 ffmpeg解封装获取数据包
/* header *///// Created by Administrator on 2020/2/24.//#include <pthread.h>//// Created by Administrator on 2020/2/24.//#ifndef DECODEAUDIO_DEMUX_H#define DECODEAUDIO_DEMUX_Hexter...
2020-03-03 21:58:14 305
原创 链表(01)
#pragma once#ifndef _MYLIST_H_#define _MYLIST_H_template <class T> class MyList;template <class T>class ListNode{ template <class T> friend class MyList;private: T data;...
2020-03-03 21:45:06 100
原创 顺序队列
#pragma once#ifndef _MYQUEUE_H#define _MYQUEUE_Htemplate<class T>class MyQueue{public: MyQueue(int size_ = 10); ~MyQueue(); int getSize() const; bool isEmpty() const; void pop(); ...
2020-03-03 18:36:25 100
原创 顺序栈
#pragma once#ifndef _MYSTACK_H_#define _MYSTACK_H_#include <math.h>template<class T>class MyStack{public: MyStack(int size_ = 10); ~MyStack(); void pop(); // 出栈 bool isE...
2020-03-03 18:33:46 87
原创 C++ map练习
#if 1/* 员工信息有:姓名, 性别, 年龄, 电话, 工资, 工号 通过multimp进行有5名员工,为其分配部门,信息插入,显示, 保存。*/#include<iostream>#include<map>#include<vector>#include<map>#include<time.h>#incl...
2020-03-01 20:56:10 385
原创 ffmpeg 音视频同步
画面的播放肯定会快于音频,因此在播放画面的时候对每一帧进行延迟播放。1、先将得到的画面帧在入队列前转换为毫秒方便后面的计算2、获取音频当前播放时间3、从packet中的画面frame获取画面的pts 除以 1000 得到秒4、计算差值 – 这里 clock 就是上面的now_time 传递给video类// 5、延时处理, 一下代码来自 -- https://me.csdn....
2020-03-01 12:32:52 174
原创 Android OpenSLES播放pcm
// 1. 创建一个 jni 函数 public native String playPcm(String url); // 2.实现它 /* 回调函数 获取具体pcm 并播放 */void pcm_CallBack(SLAndroidSimpleBufferQueueItf bq, void * context){ int len = fread(buf, 1, 44100 ...
2020-02-26 15:35:08 258
原创 Android Studio配置JNI
准备工作:1、下载ndk链接:https://pan.baidu.com/s/1OWzJm7bUFa-OKfz7_xr9EQ提取码:w9xo2、创建Android工程下拉选择nativeC++完成之后在MainActivity有官方自带的测试例子函数实现可以Ctrl + B 进去 或者在左侧的CPP下的native-lib.cpp可以看到自己测试写一个例子-出现红色是因为还没有实...
2020-02-26 12:28:51 295
原创 shell基础
运行shell方法 1. chmod a+x myshell.sh ./myshell.sh 2. . myshell.sh 3. source myshell.sh 4. /bin/bash myshell.sh 5. sh myshell.shshell 语法 shell 只有一种数据类型 string. 定义出来的变量都是字符串与python一样var=10 取变...
2020-01-03 13:42:17 135
原创 grep和find命令常用选项
grep 查找文件内容主要参数 grep --help可查看 -c:只输出匹配行的计数 -i:搜索时不区分大小写 -h:结果不显示文件名 -n:显示结果所在文件行号 -r:未指定文件时,递归搜索当前目录文件 grep -rn "1.1.1.1" ./ 在当前目录查找包含“1.1.1.1”字符串的文件,并显示所在行号 find 查找文件(默认递归所有文件目录),一般情况下不与管...
2020-01-03 13:02:08 183
原创 nginx安装
nginx安装nginx依赖三个包1、 pcre包wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz2、 zlib包wget http://www.zlib.net/zlib-1.2.11.tar.gz3、openssl包wget https://www.opens...
2019-12-29 14:55:01 100
原创 fastDFS安装及使用
安装以及使用• 下载所需压缩包o fastdfs-5.10.tar.gzo libfastcommon-master.zip(依赖包,千万不要选择1.03以下版本的)• 找到说明书o READMEo INSTALL• 执行命令: ./make.sh sudo ./make.sh installo 安装过程中要看清楚安装信息,稍微看一下安装路径• 执行 fdfs_test ...
2019-12-29 14:51:16 241
原创 堆排序
#if 1/* parent = (i - 1) / 2 父节点 c1 = 2i + 1 子节点(左) c2 = 2i + 2 子节点(右)*/#include<iostream>void swap(int* tree, size_t max, size_t head) //交换函数{ size_t temp; temp = tree[max];...
2019-12-27 09:23:03 70
原创 epoll简单服务器
/* epoll三个重要函数, 底层红黑树 1.int epoll_create(int size); 创建 epoll 树的根节点 size:理论上最大数的节点个数,超出是会自动扩充 2.int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); 对 epoll 树的操作 添加/删除/修改 op: E...
2019-10-23 09:10:51 114
原创 快速排序
#if 1#include<iostream>void Quicksort(int* a, int start, int end){ int point = a[start]; // 基准点 int i = start, j = end; if (i >= j) { return; // 递归出口 } while (i < j) {...
2019-10-18 15:07:36 83
原创 找出字符串中出现次数最多的字符
#include <string>#include<iostream>#define NUM 128int main(){ char input[NUM] = ""; //存放数入的字符串 int b[NUM] = { 0 }; //初始化全部为0,用于给出现的字符计数 int ch = 0; //字符的ASCII码 int...
2019-10-18 15:07:18 766
原创 插入排序
#if 1/* 插入排序 { 3, 4, 6, 2, 7, 1 }; 如果当前元素大于后面一个元素则把当前元素赋值给后面一个 再把key复制给当前元素 第一次 key = 4 不符合条件 直到 key = 2 当key为第一个位置的时候或者key大于前一个的时候停止 key赋值给当前位置的值*/#include<iostream>void insert...
2019-10-18 15:06:59 68
原创 冒泡排序
#if 1/* 比较当前位置和后面的大小 符合条件则进行交换 交换 n-1 次 重复这个交换 n次*/#include<iostream>void bubble(int *array, int n);void bubblesort(int* array, int n);int main(){ int a[6] = { 3, 7, 4, 6, 2, 1 }; /...
2019-10-18 15:06:51 43
原创 选择排序
#if 1/* 选择排序 每次选出数组的最大值 与 最后一个交换 然后在 筛选 最大值之前的 最大值 与最大值的前一个在交换 依次类推。。*/#include<iostream>//select sortvoid select_sort(int* p, size_t n){ int a = n; while (n > 1) //重复 n - 1 次 ...
2019-10-18 15:06:44 48
原创 马踏棋盘
#if 1#include<iostream>#include<ctime>#include<Windows.h>#include<thread>#define X 5#define Y 5int chess[X][Y];// 马 的 下 一 步 是 否 可 行int nextxy(int* x, int* y, size_...
2019-10-18 15:06:36 67
原创 二分法
#if 1#include<iostream>int main(){ int a[13] = {}; for (int i = 0; i < 13; i++) { a[i] = i + 2; } int num = 1; int begin = 0; int end = 12; int mid = (end + begin) / 2; for ...
2019-10-18 15:06:31 76
原创 BF查找匹配算法
#if 1#include<iostream>#include<string>void BF(std::string s1, std::string s2){ int n = 0; int a = 0; for (int i = 0; i < s1.size(); i++) //迭代主串 { if (s2[n] == s1[i]) ...
2019-10-18 15:06:11 148
原创 KMP算法
#if 0#include<iostream>#include<string>void Prefix_table(char subarr[], int prefix[], int len){ // 创建前缀表(next数组) int subarrpos = 0; //前缀表的值 int i = 1; //字符串索引值 由于从第二个开始 所以i ...
2019-10-18 15:05:54 60
原创 归并排序
#include<iostream>// 归并排序--递归实现// 排序并且合并数组void combinae(int *left, int *right, int left_size, int right_size){ int i = 0, j = 0, k = 0; int maxsize = right_size + left_size; int* temp =...
2019-10-18 15:05:49 77
原创 希尔排序
#if 1#include<iostream>// 在插入排序的基础上void shell_sort(int* k, int len){ int i, j, temp = 0; int gap = len; do { // 随便选一个跨度 // 直接插入排序的每一次进行数个比较改为 每一次 进行逐跨度个比较 // 只要把每一次递增或者递减 1 改为递增或...
2019-10-18 15:05:43 81
原创 创建简单二叉树并遍历
#if 1#include<iostream>// 创建节点typedef struct node{ int data; // 每个树的根节点 struct node* left; // 左节点 struct node* right; // 右节点}Node;//前序遍历void preorder(Node *node){ if (node != N...
2019-10-18 15:05:37 142
原创 线索二叉树
#include<iostream>#include<stdlib.h>struct Node{ int value; Node *left; Node *right;};struct Tree{ Node *tree;};void creat(Tree *p, int data){ Node *node = ...
2019-10-18 15:05:31 113
原创 Linux gdb 调试模式
Linux gdb 调试编译调试版本的文件 gcc -o app main.c add.c -I ./include -g 启动gdb调试 gdb app 若有main()有设置参数则可以在gdb下设置传递参数 set args .....gdb一些命令 1.run:执行整个程序 2.start:开始调试 3.next(n):逐条语句执行 4.step:逐条语句执行,...
2019-10-18 15:05:15 316
原创 Linux gdb调试core
问题: 遇到:段错误(核心已转储) Segmentation fault (core dumped) 使用gbd core调试 1.设置生成core文件大小, 一般使用ulimit -c unlimited 2.重新执行可执行文件./a.out, 可以看到生成了core文件 3.开启gdb core 调试:gdb a.out core 可以看到程序运行到哪死掉 4.如果执行多个程...
2019-10-18 15:05:10 159
原创 Linux-libevent创建简单服务器端
/************************************************************************* > File Name: ev_fifo_s.c > Author: mushinn > Mail: 893379670@qq.com > Created Time: 2019年10月...
2019-10-18 15:05:04 293
原创 Linux简单epoll服务器
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdlib.h>#include <sys/socket.h>#include<sys/epoll.h>#include...
2019-10-18 15:04:58 117
原创 Linux下libevent的简单客户端
/* * libevent 客户端 * */#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <stdlib.h>#include <sys/socket.h>#include <event2/bufferevent.h&...
2019-10-18 15:04:28 165
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人