自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

love12fly@sina.com

记录自己的学习过程!

  • 博客(120)
  • 资源 (3)
  • 收藏
  • 关注

原创 链表成环问题

利用字节对齐判断链表是否有环,主要的思路就是根据字节对齐规则将字节空隙利用起来。利用字节空隙来标记遍历过的节点。#include <stdio.h>//链表节点struct Node{ int value; struct Node *next;};//创建链表struct Node* createNode(int n){ //头节点 struct Node *head = new struct Node; head->value =

2021-09-28 11:28:10 209

原创 手写队列、栈

//链表节点struct Node{ int val; struct Node* next;};//队列class queue{private: struct Node* top; //取数据端 struct Node* rear; //放数据端 int count; //元素个数计数器public: queue(){ rear = new struct Node; rear->next = NULL;

2021-09-10 16:18:52 201

原创 二叉树的遍历

#include <stdio.h>#include <stdlib.h>#include <stack>using namespace std;struct Node{ int val; struct Node *left; struct Node *right;};//先序递归遍历void fdfs(struct Node *root){ if(root == NULL){ return;

2021-09-07 13:57:09 188

原创 Windows 多线程编程

#include<string>#include<iostream>#include<process.h>#include<windows.h>using namespace std; //声明互斥量句柄HANDLE hmu; //线程绑定的函数返回值和参数是确定的,而且一定要__stdcallunsigned __stdcall threadFun(void *param){ WaitForSingleObject(hmu, I

2021-09-01 17:12:59 163

原创 信号量编程实现进程互斥

无信号量时#include <stdio.h>#include <unistd.h>#include <sys/ipc.h>#include <sys/sem.h>#include <sys/shm.h>#include <string.h>int main(){ /*子进程*/ if(fork() == 0){ int n = 5; /*模拟对临界资源的访问*/

2021-08-20 15:26:50 156

原创 Linux popen函数的使用

#include <stdio.h>int main(){ /*缓存数组*/ char buf[512] = {0}; /*将ls -l执行的结果写入管道*/ FILE *fp = popen("ls -l","r"); if(fp == NULL){ perror("popen"); return -1; } /*将结果从管道中读到缓存*/ fread(buf,1,sizeof(buf),f

2021-08-06 14:04:55 145

原创 Linux 使用文件锁实现多进程的文件互斥访问

#include <sys/wait.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h>#include <stdio.h>#include <sys/file.h>int main(){ pid_t pid = fork(); //创建子进程 if(pid == -1){

2021-08-06 11:44:32 491

原创 C++ 单例模式

有缺陷的懒汉式#include <iostream>using namespace std;class Single{ private: /*构造函数私有化*/ Single(){ cout<<"constructor created"<<endl; } /*禁用拷贝构造函数*/ Single(Single &) = delete;

2021-07-29 15:17:23 80

原创 Linux 时间戳获取及转换

#include <stdio.h>#include <time.h>int main(){ time_t t; //时间戳 struct tm *p; time(&t); //获取时间戳 p=localtime(&t); //将时间戳转换为本地时间 printf("时间戳:%ld\n",t); printf("%d-%d-%d %d:%d:%d\n",(1900+

2021-07-21 13:48:09 430

原创 pugixml读写xml文件

pugixml包含三个文件,分别为pugixml.cpp,pugixml.hpp,pugiconfig.hpp.(没有的话需自行下载),使用时将这三个文件添加到工程中,并包含相应的头文件。编译时一定要编译pugixml.cpp文件。实例代码#include <iostream>using namespace std;#include "pugixml.hpp"#include "pugiconfig.hpp"using namespace pugi;bool ReadXm

2021-07-12 14:58:32 2066

原创 Linux网络编程

server.c#include <stdlib.h>#include <stdio.h>#include <sys/types.h> /* See NOTES */#include <sys/socket.h>#include <arpa/inet.h>#include <netinet/in.h>#include <string.h>#include <unistd.h>

2021-07-02 23:03:14 81

原创 条件控制实现线程同步

#include <stdio.h>#include <pthread.h>#include <unistd.h>#include <stdlib.h>int data = 0; //互斥量pthread_mutex_t mutex; //锁pthread_cond_t cond = PTHREAD_COND_INITIALIZER; //创建条件变量,并用宏进行初始化//线程t1处理函数void *fun1(void *param)

2021-07-01 22:29:49 75

原创 线程同步之互斥量加锁解锁

不加锁的代码#include <stdio.h>#include <pthread.h>#include <unistd.h>int data = 0; //互斥量//线程t1处理函数void *fun1(void *param){ for(int i=0;i<5;i++){ printf("t1 : data = %d\n",data++); sleep(1); }}//线程t2处理函数void *fun2(voi

2021-07-01 20:44:22 90

原创 Linux多线程编程

#include <stdio.h>#include <pthread.h>//子线程任务void *fun1(void *param){ static char *p = "\"my work has finished\""; //子线程返回数据 printf("t1:my id is %ld\n",(unsigned long)pthread_self()); printf("t1:param = %d\n",*((int

2021-06-29 22:03:12 76

原创 Linux进程间通信之信号携带消息

signalget.c#include <stdio.h>#include <signal.h>#include <sys/types.h>#include <unistd.h>//信号捕获回调函数,软中断void handler(int signum,siginfo_t *info,void *flag){ printf("sinum = %d\n",signum); //信号编号 if(flag!=NULL) //判断消

2021-06-29 00:00:52 228

原创 Linux进程间通信之共享内存

shmw.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>int main(){ int shmid; key_t key; char *shmaddr;

2021-06-28 21:15:46 81

原创 Linux进程间通信之消息队列

进程1#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <string.h>//消息队列链表结点struct msgbuf { long mtype; /* message type, must be > 0 */ char

2021-05-21 22:45:49 100 2

原创 Linux进程间通信之管道通信

匿名管道(用于亲缘进程间通信)#include <stdio.h>#include <stdlib.h>#include <fcntl.h> /* Obtain O_* constant definitions */#include <unistd.h>int main(){ int fd[2];//管道参数,fd[0]:读端,fd[1]:写端 char buf[1024] = {0}; if(

2021-05-21 15:27:09 95

原创 Linux文件光标移动

#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>int main(){ int fd; //打开文件 fd = open("./demo1file",O_RDWR

2021-05-19 17:29:29 236

原创 Linux文件读取

#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>int main(){ int fd; char *buf =(char *) malloc(15); //开辟15个字节

2021-05-19 17:02:38 188

原创 Linux文件写入

#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>int main(){ int fd;//文件描述符 char *buf = "Linux filewrite";//要写

2021-05-19 16:36:11 269 2

原创 Linux打开及创建文件

#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>int main(){ int fd; //文件描述符 fd = open("./demo1file",O_RDWR|O_CREAT,0600);//如果文件不存在创建新的文件,0600表示可读可写权限 printf("%d\n",fd); return 0;

2021-05-19 15:36:42 101

原创 python 读取串口数据并绘制多路实时动态波形

import pyqtgraph as pgimport numpy as npimport serialimport arrayfrom threading import Threaddef Rx(): h = int.from_bytes(ser.read(1), 'little') #高8位 l = int.from_bytes(ser.read(1), 'little') #低8位 ans = (h << 8) + l #对ADC的值进行译码

2021-03-22 23:02:46 2317 3

原创 opencv实现人脸识别

解析全在注释里,opencv为第三方库,需要自己安装,安装方法:pip install opencv-python其他必要的库请读者自行安装,这里不再赘述。opencv库中的方法精度并不是很高,影响因素非常多,可以采用降噪等方法提高精度。开源的opencv库用于平时学习还是非常有帮助的,至于想做企业级产品还是建议另寻他法。import cv2import numpy as npimport osimport shutilimport matplotlib.pyplot as plt#

2021-03-13 18:29:20 215 2

原创 Linux(树莓派)字符设备驱动编写、编译、测试

编写驱动代码寄存器的操作参考芯片手册。#include <linux/fs.h> //file_operations声明#include <linux/module.h> //module_init module_exit声明#include <linux/init.h> //__init __exit 宏定义声明#include <linux/device.h> //class devi.

2021-03-11 16:06:34 161

原创 基于树莓派的Linux字符设备驱动框架

#include <linux/fs.h> //file_operations声明#include <linux/module.h> //module_init module_exit声明#include <linux/init.h> //__init __exit 宏定义声明#include <linux/device.h> //class devise声明#include <linux

2021-03-10 22:56:07 70

原创 使用交叉编译工具进行Linux内核(硬件平台-树莓派3b)编译

安装交叉编译工具链sudo apt-get install gcc-arm-linux-gnueabihf下载Linux内核源码Linux内核源码下载内核配置使用厂家提供的config进行配置,树莓派1的工程是bcmrpi_defconfig;树莓派2、3的工程是bcm2709_defconfig。ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KERNEL=kernel7 make bcm2709_defconfig此命令功能是获取bcm2.

2021-03-10 21:54:58 173

原创 暴力破解WiFi密码

需要手动安装pywifi库(直接pip install pywifi的方法不行),手动安装方法自行百度。import itertools as itsimport pywififrom pywifi import constimport timeimport datetime# 测试连接,返回链接结果,pwd为密码,wifi_name为要破解的WiFi名称def wifiConnect(pwd, wifi_name): # 抓取网卡接口 wifi = pywifi.PyWi

2021-03-10 13:40:24 4232

原创 跑步锻炼

import datetimestart = datetime.date(2000,1,1)end = datetime.date(2020,10,1)dt = datetime.timedelta(days=1) #时间间隔为一天cnt = 0while start<=end: if start.weekday()==0 or start.day==1: cnt+=2 else: cnt+=1 start+=dtprint(.

2021-03-04 21:26:26 96 1

原创 树莓派串口编程

初次使用树莓派串口编程,需要配置。/* 修改 cmdline.txt文件 */>cd /boot/>sudo vim cmdline.txt删除【】之间的部分dwc_otg.lpm_enable=0 【console=ttyAMA0,115200】 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait/*修改 inittab文件 */

2021-03-03 14:28:43 82 1

原创 wiringPI库实现继电器操作

#include <stdio.h>#include <wiringPi.h>int main(){ if(wiringPiSetup ()==-1){ //硬件初始化函数 printf("初始化失败!\n"); return -1; } pinMode (7, OUTPUT);//io口模式设置 digitalWrite(7,HIGH);//输出高

2021-03-03 12:19:33 73

原创 python绘制矩阵热力图

import seaborn as snsimport pandas as pdimport matplotlib.pyplot as pltdf = pd.read_excel(r'D:\xxx.xlsx').set_index('xxx')fig, ax = plt.subplots(figsize = (9,9))sns.heatmap(df,annot=True, vmax=1,vmin = 0, xticklabels= True, yticklabels= True, square

2021-02-08 14:33:57 1133 2

原创 networkx绘制有向图

import pandas as pdimport matplotlib.pyplot as pltimport networkx as nxG = nx.DiGraph()df = pd.read_csv('data.csv').set_index('xxx')nodes = []edges = []cnt = 0groupd = df.groupby('xxx')for name,group in groupd: if cnt == 80: break

2021-02-06 20:59:56 1431

原创 基于sklearn库的神经网络进行预测

from sklearn.neural_network import MLPRegressorimport numpy as npmlp = MLPRegressor(solver='lbfgs',hidden_layer_sizes=(3,2),activation='logistic')X = np.array([ [-2, -1], # Alice [25, 6], # Bob [17, 4], # Charlie [-15, -6], # Diana]

2021-02-05 00:43:21 1415 2

原创 python 求解非线性规划问题

题目:代码:from scipy.optimize import minimizeimport numpy as npfrom mpl_toolkits.mplot3d import Axes3Dfrom matplotlib import pyplot as plt# 目标函数:def func(x): return 10 - x[0] ** 2 - x[1] ** 2# 约束条件,包括等式约束和不等式约束def con(): cons = ({'type':

2021-01-22 16:18:15 1033

原创 相关性分析(求相关系数)

代码import matplotlib.pyplot as pltimport numpy as npplt.figure()# 数据集x = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30]y = [22.44, 92.17, 31.74, 51.37, 20.92, 20.67, 20.32, 90.05, 19.84, 19.59]r = np.corrcoef(x,y)[0][1]print('相关系数r=',r)# 绘制散点plt.scatte

2021-01-15 17:41:39 716

原创 单元拟合(以线性拟合为例)

import numpy as npimport matplotlib.pyplot as pltfrom scipy import optimizedef f_1(x, a, b): return a * x +bplt.figure()# 拟合点x0 = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30]y0 = [22.44, 22.17, 21.74, 21.37, 20.92, 20.67, 20.32, 20.05, 19.84, 19

2021-01-15 16:39:48 150

原创 平均值、方差、标准差

import numpy as nparr = [1,2,3,4,5,6,7,8,9,10]avrege = np.mean(arr) #求平均值f_var = np.var(arr)b_var = np.std(arr)print("平均值为:",avrege)print("方差:",f_var)print("标准差:",b_var)

2021-01-15 15:26:07 215

原创 样条插值法

一维插值法代码import numpy as npfrom scipy import interpolateimport pylab as pltx=np.linspace(0,10,11)y=np.cos(x)xnew=np.linspace(0,10,51)plt.plot(x,y,"ro") #红色圆点for kind in ["nearest","zero","slinear","quadratic","cubic"]:#插值方式 #"nearest","zero"为

2021-01-14 17:45:48 830 1

原创 蒙特卡洛法(随机取样法)

y=x^2、y = 12 − x与x 轴 在第一象限围成一个曲边三角形。设计一个随机试验,求该图像面积的近似值。解: 设计的随机试验思想如下:在矩形区域 [0, 12] * [0, 9] 上产生服从均匀分布的 10^6 个随机点,统计随机点落在曲边三角形的频数,则曲边三角形的面积近似为上述矩形面积乘于频率。代码import random#random.random()产生的是0~1的随机数x = [random.random() * 12 for i in range(0, 10**6)]y =

2021-01-14 16:07:04 1447

基于Python的数字滤波器设计

基于Python的数字滤波器设计

2021-01-07

ChatSystem.zip

1.实现了多人聊天,而不是单一的双人聊天。 2.实现了多线程编程,解决了单线程消息阻塞和不能并发的问题。 3.实现了动态的好友列表,交互感更强,有比较不错的用户体验。 4.实现了群聊与私聊并存,使功能更加的完善。 5.有比较简洁美观的用户界面,使用更加舒心。

2020-08-19

研究生信息管理系统.zip

C语言课程设计完成的一个简易研究生信息管理系统,用于学习,记录自己的学习过程。该作品主要使用链表这种数据结构,方便动态的更新数据,摆脱常规的数组定长限制,数据用文件的形式进行存储。不做商业用途。

2020-04-15

空空如也

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

TA关注的人

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