自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 C++获取类私有成员指针

获取类首地址,根据成员定义顺序去计算想要的私有成员地址。class A{private: int a; float b;public: A() { a = 1; b = 1; }public: float getB() { return b; }};void test(){ A a; float* p = (float*)((int*)(&a) +

2020-11-09 17:19:09 782

原创 jpg转yuv420sp——C++

// If you use visual studio, define _CRT_SECURE_NO_WARNINGS to use unsafe function fopen.// #define _CRT_SECURE_NO_WARNINGS#include <opencv2/opencv.hpp>#include <iostream> using namespace std;using namespace cv;enum class YUV420SP {

2020-10-27 14:03:41 1337 1

原创 ClangFormat官方文档

官方链接

2020-04-24 14:47:24 384

原创 并查集模板

public class UF { private int[] id; private int[] sz; public UF(int N) { id = new int[N]; sz = new int[N]; for (int i = 0; i < N; i++) { id[i] = i;...

2020-03-20 09:35:28 110

原创 LeetCode 1160. 拼写单词

题目传送门简单的哈希。class Solution {public: int countCharacters(vector<string>& words, string chars) { int res = 0; int ch[26] = { 0 }; for (char c : chars) { ++ch[c - 'a']; } for (s...

2020-03-17 10:03:32 110

原创 LeetCode 第 180 场周赛

5356. 矩阵中的幸运数class Solution {public: vector<int> luckyNumbers (vector<vector<int>>& matrix) { vector<int> result; for(int i = 0; i < matrix.size();...

2020-03-15 11:41:17 85

原创 动态规划 —— 最长上升子序列

给定一个无序的整数数组,找到其中最长上升子序列的长度。题目传送门示例:输入: [10,9,2,5,3,7,101,18]输出: 4解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。简单的dp,状态转移方程,时间复杂度O(n^2)dp[i] = max(dp[i],dp[j]+1)class Solution {public: int lengthOfLI...

2020-03-14 10:32:06 141

原创 LeetCode 543. 二叉树的直径

题目传送门简单的递归题目。class Solution {public: int ans = 0; int depth(TreeNode* rt) { if (rt == NULL) { return 0; } int l = depth(rt->left); int r = depth(rt->right); ans = max(ans, l...

2020-03-10 09:55:58 69

原创 LeetCode 第 179 场周赛

5352. 生成每种字符都是奇数个的字符串class Solution {public: string generateTheString(int n) { string result; if(n&1) { for(int i = 0; i < n;i++) { ...

2020-03-08 13:12:56 102

原创 LeetCode 643. 子数组最大平均数 I

题目传送门class Solution {public: double findMaxAverage(vector<int>& nums, int k) { int sum = 0; for (int i = 0; i < k; i++) { sum += nums[i]; } double result = sum * 1.0 / k;...

2020-03-07 11:19:38 73

原创 LeetCode 326. 3的幂

题目传送门class Solution {public: int v[20] = {1,3,9,27,81,243,729,2187,6561,19683,59049,177147,531441,1594323,4782969,14348907,43046721,129140163,387420489,1162261467}; bool isPowerOfThree(int n...

2020-03-06 15:13:27 99

原创 LeetCode 906. 超级回文数

题目传送门class Solution { long long v[70] = { 1, 4, 9, 121, 484, 10201, 12321, 14641, 40804, 44944, 1002001, 1234321, 4008004, ...

2020-03-04 16:22:11 102

原创 LeetCode 14. 最长公共前缀

题目传送门class Solution {public: string longestCommonPrefix(vector<string>& strs) { string result = ""; if(strs.size() == 0) { return result; } for (int i = 0 ; i< strs[0]...

2020-03-03 19:54:41 90

原创 LeetCode 面试题50. 第一个只出现一次的字符

题目传送门class Solution {public: map<char, int> m; char firstUniqChar(string s) { for(int i = 0; i < s.length();i++) { if(m.find(s[i]) == m.end()) { m[s[i]] = 1; } el...

2020-03-03 08:28:42 145

原创 Leetcode 7. 整数反转

class Solution {public: int reverse(int x) { bool minus = x < 0; if (x == -2147483648) { return 0; } x = x < 0 ? -x : x; char ch[15]; sprintf(ch,"%d", x); int length = s...

2020-03-02 18:13:46 73

原创 C++替代标记

标记 含义 and &amp;&amp; and_eq &amp;= bitand &amp; bitor | compl ~ not ! not_eq != or || or_eq |=...

2018-10-04 19:34:49 384

原创 C++关键字解释

alignas改变一个数据类型的对齐属性。 对齐指地址值必须被某个值整除, 比如alignas(16) int a;表示a的地址必须被16整除。alignof查询类型的对齐要求。asm插入一个汇编指令。auto声明一个自动变量bool布尔数据类型,只有true和false两种值。break跳出最近一层循环。case与switch结合使用。ca...

2018-10-04 19:20:33 616

原创 关于win7平台Qt无法编译的问题

或许可以试试把工程路径中的中文名改成英文名。

2018-09-07 11:13:56 607

原创 Mybatis简单例子

MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。要使用 MyBatis, 只需将 myb...

2018-08-03 15:54:52 11895 1

原创 PowerMock常用测试场景

PowerMock是一个单元测试模拟框架,他的出现是为了解决EasyMock、JMock、Mockito根本没有办法完成的工作,比如Mock一个static方法等等,更多的将PowerMock 理解为对现有Mock 框架的扩展和进一步封装是比较贴切的,PowerMock 现在目前提供了两套UT(Unit Test)框架的封装,请看下图。 maven工程PowerMock的获取需要在pom中...

2018-08-03 14:10:36 1088

原创 QString将多个空格、制表符替换成单个空格。

方法如下:QString qString;qString.replace(QRegExp("[\\s]+"), " ");

2018-07-29 23:48:45 2175

原创 Qt 解决中文乱码问题

在main函数开头加入如下代码:QTextCodec *codec = QTextCodec::codecForName("UTF-8");QTextCodec::setCodecForLocale(codec);

2018-07-29 21:29:43 142

原创 C++ 拷贝构造函数

参数请带上const 参数请带上const 参数请带上const

2018-07-24 22:49:53 69

原创 Qt更改默认编辑模式(insert/replace)

Qt更改默认编辑模式(insert/replace) alt+v 两次

2018-05-20 20:03:47 2762

原创 qt安装 升级访问权限时出现错误

以管理员权限运行安装程序即可。

2018-05-08 19:10:47 6180

原创 378. Kth Smallest Element in a Sorted Matrix

原题链接 Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted...

2018-04-17 15:15:47 91

原创 1. Two Sum

原题链接 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not ...

2018-04-17 13:42:17 84

原创 561. Array Partition I

原题链接 Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large ...

2018-04-17 10:22:26 88

原创 441. Arranging Coins

原题链接 You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be ...

2018-04-14 12:15:36 100

原创 415. Add Strings

原题链接 Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is &lt; 5100. Both num1 and num2 contains...

2018-04-14 11:41:16 72

原创 258. Add Digits

原题连接 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has...

2018-04-14 11:34:14 81

原创 67. Add Binary

原题连接 Given two binary strings, return their sum (also a binary string). For example, a = “11” b = “1” Return “100”.思路:模仿整数加法。AC代码:class Solution {public: string addBinary(...

2018-04-14 11:21:17 69

原创 717. 1-bit and 2-bit Characters

原题连接 We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by sev...

2018-04-13 17:23:01 96

原创 QT 加载.so动态链接库

例子:文件路径/usr/local/lib/libtest.so在.pro文件中写LIBS +=-L/usr/local/lib -ltest

2018-04-07 14:52:56 8578 1

原创 牛客网-数据库SQL实战

查找最晚入职员工的所有信息select * from employees order by hire_date desc limit 0,1 查找入职员工时间排名倒数第三的员工所有信息select * from employees order by hire_date desc limit 2,1 查找当前薪水详情以及部门编号dept_noselect salari...

2018-04-07 14:49:24 1094

原创 SQL中PK、UK、DF、CK、FK的意思

PK 主键constraint primary keyUK 唯一约束constraint unique keyDF 约束默认constrint default forCK 检查约束constraint check()FK 主外键关系constraint foreign references...

2018-03-23 17:28:53 33536 1

空空如也

空空如也

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

TA关注的人

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