自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 源码编译 Qt 6.2

Qt 6.2 源码构建 (动态库和静态库)Qt 6.2.0 源码构建,win10、ubuntu、Mac平台下的动态库版本、静态库版本.

2021-10-16 19:34:08 6372 12

原创 84. Largest Rectangle in Histogram

84.Largest Rectangle in HistogramGiven an array of integers heights representing the histogram’s bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.Example 1:Input: height = [2,1,5,6,2,3]Output: 10E

2021-06-24 23:18:32 190

原创 图形学之光线与三角形求交

三角形平面内任意点P可由三角形三个顶点表示:P=wA+uB+vCP = wA + uB + vCP=wA+uB+vC根据重心坐标性质w + u + v = 1:P=(1−u−v)A+uB+vCP = (1 - u - v)A + uB + vCP=(1−u−v)A+uB+vCP=A−uA−vA+uB+vC=A+u(B−A)+v(C−A)P=A - uA - vA + uB + vC = A + u(B - A) + v(C - A)P=A−uA−vA+uB+vC=A+u(B−A)+v(C−A)光线

2021-04-16 00:30:05 1521

原创 链表的应用

链表在我们的实际开发项目中有着广泛的应用,Linux内核实现了一个精妙的链表,可以方便地嵌入到任何一个数据结构中,而不用为每个数据结构单独写一个插入、删除等操作。本文参照内核链表实现,实现了一个更加精炼的链表实现,剔除了不常用的操作,保留最常用的插入、删除、遍历操作,重写或修改了链表结构、插入删除函数,使实现更为精炼、清晰。嵌入位置放在结构体起始位置,由于结构体第一个变量的地址和整体结构体的地址一致,这样方便我们从节点类型到结构体类型的转换,具体见下文的测试用例。链表和结构体定义:typedef s

2021-01-19 12:59:54 1347

原创 Bresenham‘s line algorithm 布雷森汉姆直线算法

1、线性方程首先我们假设要绘画的直线斜率大于0小于1.截距式直线方程如下:y=f(x)=mx+by=f(x)=mx+by=f(x)=mx+b现在我们要从点(x0,y0)(x_0,y_0)(x0​,y0​)到点(x1,y1)(x_1,y_1)(x1​,y1​)画一条直线,该直线的斜率有:m=y1−y0x1−x0=ΔyΔxm=\frac{y_1-y_0}{x_1-x_0}=\frac{\Delta y}{\Delta x}m=x1​−x0​y1​−y0​​=ΔxΔy​所以我们有:y=ΔyΔxx+b

2020-09-08 01:15:32 758

原创 Makefile常用参数

一、make编译过程//预处理,#开头的代码全被解决掉(预编译,包含库,宏定义等等)hello.i上千行.gcc -E hello.c >> hello.i//编译,检查语法错误,生成.s文件,汇编代码,大概26行.gcc -S hello.i//汇编。产生后缀.o的object目标文件,二进制,不可以运行,缺少库信息.gcc -c hello.s总结:预处理.i => 编译.s => 汇编.o => 链接二、常见参数-f :执行make的时候,

2020-08-24 10:49:56 2965

原创 美化makefile输出

以learningOpenGL练习代码为例,目录结构如下:LearnOpenGL │───── include │ ├─ glad //glad头文件 │ ├─ GLFW //GLFW库头文件 │ └─ KHR //glad头文件 │────── llib │ ├─ libglad.a //glad.c编译成了静态库 │

2020-08-22 12:38:24 277

原创 43. Multiply Strings [LeetCode]

大整数相乘,假设输入为非负,从左到右依次解析。void add_char(string &s, int index, int val){ int tmp = s[index] - '0' + val; s[index] = tmp % 10 + '0'; if (tmp / 10 > 0) add_char(s, index - 1, tmp / 10);}string multyply(const string &num1, const

2020-06-24 18:31:12 164

原创 在编译期效验结构体偏移和结构体大小

sizeof和offsetof会返回无符号数据,与size相减会转为无符号数,导致数组定义过大,从而编译失败。#include <stdio.h>#include <stddef.h>//long unsigned int#define ASSERT_OFFSET(type, member, size) \static inline assertOffSetOf##member(){\ char up[offsetof(type,member) - size

2020-05-28 21:48:39 559

原创 数组在内存中是连续存放的吗

用栈声明的时候很明显,都是连续的。在堆上的时候,由于是分批次分配内存(首先new出或malloc多少行,然后每一行再分别new),因此其存放是平行的几条连续存储,每一行是连续的,行与行之间并不连续。为此,我们尝试创建一个2X4的二维矩阵如下A B C DE F G H打印其地址来证明。代码如下,为了直观,略去了一些安全检查。#include <stdio.h>#include <stdlib.h>#include <iostream>using names

2020-05-28 18:45:38 10070 2

原创 关于位操作

有符号类型用最高位表示,正数最高位0;复数最高位1;负数用正数的反码加1表示(即用正数的补码表示),比如一个4位的类型:+7[0111],反码 ->[1000],反码加1 ->[1001].最终这个[1001]即+7[0111]的补码。一个机器4位:正数范围[0001]~[0111],即1-7,[2^3-1]负数范围[1000]~[1111],即-8至-1[1000]为何为-8?从补码反推:先减一变为[0111],再取反码,[1000]->8[1111]为何为-1?从补

2020-05-16 13:52:31 275

原创 Linux设备驱动程序

第一章 设备驱动程序简介  设备驱动程序在Linux内核中扮演着特殊的角色。它们是一个个独立的“黑盒子”,使某个特定硬件响应一个定义良好的内部编程接口,这些接口完全隐藏了设备的工作细节。用户的操作通过一组标准化的调用执行,而这些调用独立于特定的驱动程序。将这些调用映射到作用于实际硬件的设备特有操作上,则是设备驱动程序的任务。这个编程接口能够使得驱动程序独立于内核的其他部分而建立,必要的情况下可在...

2020-03-17 22:18:56 1582

原创 Linux动态库和静态库

库是预编译的目标文件(.o)的集合,它们可以被链接进程序。printf等C标准库在 /usr/lib/libc.a,它包含ANS1/ISO标准指定的函数。对每一个C程序,libc.a默认被链接。静态库在程序编译时会被连接到目标代码中,程序运行时将不再需要该静态库。编译之后程序文件大,但加载快,隔离性也好。动态库在程序编译时并不会被连接到目标代码中,而是在程序运行是才被载入,因此在程...

2019-09-27 15:25:24 203

原创 Ubuntu映射远程驱动器

1.sudo apt-get install cifs-utils2.sudo gedit /etc/nsswitch.conf找到hosts: files mdns4_minimal [NOTFOUND=return] dns添加winshosts: files mdns4_minimal [NOTFOUND=return] wins dns3.创建一个校验文件gedit ~/.s...

2019-09-04 13:18:19 475

原创 常用的线程属性

//线程属性结构体如下:typedef struct{ int detachstate; //线程的分离状态 int schedpolicy; //线程调度策略 struct sched_param schedparam; //线程的调度参数 int ...

2019-08-21 17:27:19 678

原创 套接字选项

一、函数#include <sys/socket.h>int getsockopt(int sockfd, int level, int optname, void *val, socklen_t *optlen);int setsockopt(int sockfd, int level, int optname, const void *val, socklen_t...

2019-08-21 17:24:29 215

原创 VS code 空格和tab相关设置

一、tab一律用4个空格不要检测到第一个是tab,就后面都用tab,这样会覆盖默认设置。tabSize 查找,取消 tab size/spaces automatically detected when a file is opened.二、显示空格和tabrenderControlCharacters 查找,选中勾选框,即可显示tab.renderWhitespace 查找,选择a...

2019-08-21 17:21:01 1671

原创 进程间通信_unp_v2

实验楼学习笔记2019/08/15.第4章 管道和FIFO4.1 概述管道是最初的UNIX IPC形式,可追溯到1973年的UNIX第三版。FIFO有时称为有名管道(named pipe).管道和FIFO都是使用read和write函数访问的。4.3 管道所有Unix都提供管道,它由pipe函数创建,提供一个单路(单向)数据流。#include <unistd.h>i...

2019-08-15 15:10:07 198

原创 UNIX环境高级编程

APUE 学习笔记 2019-6-12 实验楼版本 第1章 UNIX基础知识 从严格意义上说,可将操作系统定义为一种软件,它控制计算机硬件资源,提供程序运行环境,通常将这种软件称为内核(kernel)。内核的接口被称为系统调用(system call),公用函数库构建在系统调用接口之上,应用程序即可使用公用函数库也可使用系统调用。当创建一个新目录时,自动创建了两个文件名:.(称为点)和.....

2019-08-15 14:11:30 506

原创 vim学习笔记

定义快捷键的前缀为; let mapleader=";"任何时候都要使用非递归映射:nnoremap、vnoremap.(nore非递归的意思).一、多文件与多窗口操作vim -r 1 恢复1vim 1 2:n 转到2:N 转到1:e 3 新打开3:e# 回到前一个文件:b 2 回到2;h/j/k/l或;gg 窗口间跳转二、视图操作普通模式下输入v进入选择模式shif...

2019-06-09 21:21:23 220

原创 二进制字符串的所有可能组合

1.数据以0和1二进制的形式传输,由于网络噪声,一些位数接收变成'?",找出所有可能的组合。(中兴2018.9.15)测试用例:Testcase 1:Input:11100??11Expected Return Value:111000011 111000111 111001011 111001111Testcase 2:Input:?01??00...

2018-09-15 11:39:29 1558

原创 如何用Amira分割DICOM图像

1.点击OpenData加载文件,全部选中后点击Load,一般会有成百上千个图片,稍等片刻即可载入。2.点击OrthoSlice,或右键工程选中OrthoSlice。3.右键工程依次选中Labeling-&gt;LabelVoxel.选中之后修改下方的属性,Regions只保留Bone选项,然后回车,把下方的Bone-Inside进度条拉到最大,一次勾选上subvoxel accu...

2018-09-04 18:12:28 5450 5

原创 50. Pow(x, n) [LeetCode]

Implementpow(x,n), which calculatesxraised to the powern(xn).//二分法x^n=x^(n/2)*x^(n/2)*x^(n%2)//分治法class Solution {public: double myPow(double x, int n) { if (n &lt; 0)return power(x, ...

2018-07-26 10:12:11 371

原创 28. Implement strStr() [LeetCode]

28.Implement strStr()ImplementstrStr().Return the index of the first occurrence of needle in haystack, or-1if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Outp...

2018-07-11 13:37:31 304

原创 74. Search a 2D Matrix [LeetCode]

74.Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first i...

2018-07-11 12:26:34 298

原创 35. Search Insert Position [LeetCode]

35.Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no du...

2018-07-11 12:24:26 221

原创 34. Find First and Last Position of Element in Sorted Array [LeetCode]

34.Find First and Last Position of Element in Sorted ArrayGiven an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorith...

2018-07-11 12:19:40 1630

原创 66. Plus One [LeetCode]

Given anon-emptyarray of digitsrepresenting a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element i...

2018-07-08 17:38:06 245

原创 147. Insertion Sort List [LeetCode]

147.Insertion Sort List链表排序,插入排序class Solution {public:ListNode * insertionSortList(ListNode* head) {if (head == nullptr || head-&gt;next == nullptr)return head;//创建一个系统最小节点...

2018-06-30 23:26:40 512

原创 148. Sort List [LeetCode]

单链表的归并排序,常数空间,O(nlogn).先来看几个简单的链表排序问题。88.Merge Sorted ArrayGiven two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1...

2018-06-30 22:16:46 329

原创 113. Path Sum II [LeetCode]

113.Path Sum IIExample:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \7 2 5 1Return:[ [5,4,11,2], [5,8,4,5]]深度优先搜索,如果没有找到,返回时要记得...

2018-06-29 10:36:40 278

原创 105. Construct Binary Tree from Preorder and Inorder Traversal(构建二叉树) [LeetCode]

105.Construct Binary Tree from Preorder and Inorder TraversalFor example, givenpreorder =[3,9,20,15,7]inorder = [9,3,15,20,7]Return the following binary tree: 3 / \ 9 20 / \ 15 7...

2018-06-28 21:18:00 309

原创 排序算法总结

//SortTestHelper.h#ifndef _QUICK_SORT_THREE_WAYS_SORTTESTHELPER_H#define _QUICK_SORT_THREE_WAYS_SORTTESTHELPER_Hnamespace SortTestHelper { vector&lt;int&gt; generateRandomArray(int n, int ran...

2018-06-22 23:15:23 219

原创 235. Lowest Common Ancestor of a Binary Search Tree [LeetCode]

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: “The lowest common ancestor is defined between tw...

2018-06-21 15:44:13 252

原创 437. Path Sum III [LeetCode]

Find the number of paths that sum to a given value.Example:root = [10,5,-3,3,2,null,11,3,-2,null,1], sum = 8 10 / \ 5 -3 / \ \ 3 2 11 / \ \3 -2 1Return 3. The p...

2018-06-21 15:39:05 208

原创 257. Binary Tree Paths [LeetCode]

Given a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1-&gt;2-&gt;5", "1-&gt;3"]Explanation: All root-to-le...

2018-06-21 15:28:59 176

原创 112. Path Sum [LeetCode]

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Example:Give...

2018-06-21 15:19:40 220

原创 226. Invert Binary Tree [LeetCode]

Invert a binary tree.反转二叉树Example:Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis original tweetb...

2018-06-21 15:05:41 233

原创 104. Maximum Depth of Binary Tree [LeetCode]

104.Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note:A l...

2018-06-21 15:00:18 217

原创 63. Unique Paths II [LeetCode]

63.Unique Paths IINow consider if some obstacles are added to the grids. How many unique paths would there be?Example 1:Input:[ [0,0,0], [0,1,0], [0,0,0]]Output: 2Explanation:There is one ...

2018-06-18 14:45:03 204

空空如也

空空如也

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

TA关注的人

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