自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 力扣3数之和

【代码】力扣3数之和。

2023-08-09 18:23:27 282

原创 C/C++的函数名和函数指针的关系剖析 观察者模式

http://www.cnblogs.com/Esfog/archive/2012/04/23/2467249.html最近在看观察者模式的时候,看到的一片,讲的很通俗,真的很通俗。在项目中使用的是lua,在观察者模式当中,是有一个事件ID和与这个事件ID绑定的函数(与其说是函数倒不如说是函数指针),这些全部存储在一个全局的对象的table当中,一个事件ID下绑定了很多的函数名(也就是函数指针),在触发了某个事件ID之后,只需要调用这个全局对象当中的一个触发函数,就可以循环触发与这个这个事件ID绑定的函

2021-11-11 21:54:28 3110

原创 C#在unity上实现双指缩放

public class ZoomMap : UIWindow { public Image mOriginTexture; public Image mBaseSize; public Image mBg; public Image mSelectArea; Vector2 offsetPos; int min_x;//用于限制拖动图片的范围 int max_x; int

2021-11-10 09:16:31 3923

原创 设计模式之命令模式

设计模式之命令模式这里主要是学习记录,也是刚在学,也在理解。感觉得清楚一件事情:命令模式的本质是解耦命令请求与处理。所以,接下来就是三个问题,怎么理解命令请求,怎么理解处理,怎么理解解耦命令请求与处理。为了解决这三个问题,我就顺着写一个例子,解释一下class Player {public: void Jump() { cout << "玩家跳跃" << endl; } void Going() { cout << "玩家前进" <&

2021-10-29 12:30:20 117

原创 正则表达式

正则表达式可以当做为通配符的增强版,帮我们去匹配指定规则的字符串限定符:操作的对象都是一个字符?:代表前面这个字符需要出现0次或者1次,就是前面这个字符可有可无可以看到既可以匹配单词use也可以匹配单词used*:匹配0个或者多个字符,代表前面的字符可以没有,也可以有很多或者一个+:匹配出现一次以上的字符可以看到之前*匹配的两个ac都消失了,因为b需要出现一次以上{}:需要指定匹配次数指定b出现的次数为5次指定b出现的次数为1,5之间指定b出现的次数为1次以上():对多个字

2021-08-11 12:09:42 999

原创 Lua学习--------封装继承多态

在这里插入代码片print("************面向对象************")print("************封装************")--面向对象 类 其实都是基于 table来实现的--元表相关的知识点Object = {}Object.id = 1function Object:Test() print(self.id)end--冒号 是会自动将调用这个函数的对象 作为第一个参数传入的写法function Object:new() --self 代表的

2021-03-23 11:22:00 153

原创 Lua学习--------元表

***********元表************")print("************元表的概念************")--任何表变量都可以作为另一个表变量的元表--任何表变量都可以有自己的元表--当我们子表中进行一些特定操作时--会执行元表中的内容print("************设置元表************")meta = {}myTable = {}--设置元表函数--第一个参数 子表--第二个参数 元表(爸爸)setmetatable(myTable,me

2021-03-23 09:53:07 78

原创 Lua学习--------协程

print("************协同程序************")print("************协程的创建************")--常用方式-- coroutine.create()fun = function () print(123)endco = coroutine.create(fun)--协程的本质是一个线程对象print(co)print(type(co))--coroutine.wrap()co2 = coroutine.wrap(fun)

2021-03-23 08:45:46 79

原创 lua学习--------and和or

print("************特殊用法************")print("************多变量赋值************")a,b,c = 1,"123",2print(a)print(b)print(c)--多变量赋值 如果后面的值不够 会自动补nil--如果后面的值多了 会自动省略a,b,c = 1,2print(a)print(b)print(c)--nilprint("************函数的多返回值************")functi

2021-03-22 20:36:35 319

原创 Lua学习-------多脚本执行

print("************多脚本执行************")print("************全局变量和本地变量************")--全局变量a = 1b = "123"for i = 1,2 do c= "唐老鸭"endprint(c)--本地变量(局部变量)的关键字 local for i = 1,2 do local d= "唐老鸭" print(d)endprint(d)fun = function () local tt = "12

2021-03-22 20:13:46 185

原创 Lua学习-------表的操作

print("************表的公共操作************")--表中 table提供的一些公共放法t1 = {{age = 1,name = "123"},{age = 2,name = "345"}}t2 = {name = "唐老鸭",sex = "男"}--插入--将t2插入到t1的后面table.insert(t1,t2)print(t1[3].sex)--删除指定元素--remove放法 传表进去 会移除最后一个索引的内容table.remove(t1

2021-03-22 18:29:50 159

原创 Lua学习-------类

print("************类************")--Lua中默认没有面向对象 需要自己实现--成员变量 成员函数student = { --年龄 age = 1, --性别 sex = true, --成长函数 Up = function () student.age = student.age + 1 print("我成长了") end, --学习函数 Learn= function () print("好好学习,天天向上") end, In

2021-03-22 18:13:38 130

原创 Lua学习------table实现字典

print("************复杂数据类型——表2************")print("************字典************")print("************字典的申明************")--字典是由键值对构成a = {["name"] = "唐老鸭" ,["age"] = 14 , ["1"] = 5}--访问当个变量 用中括号填键 来访问print(a["name"])print(a["age"])print(a["1"])--还可以.类似成

2021-03-22 17:37:26 2035

原创 Lua学习------迭代器遍历

print("***********迭代器遍历*************")--迭代器遍历 主要是用来遍历表的--#得到长度 并不准确 一般不用#来遍历表a = {[0] = 1,2,[-1] = 3,4,5,[5]= 6}print("***********ipairs迭代器遍历*************")--ipairs遍历 还是从1开始往后遍历 小于等于0的值得不到--只能找到连续索引的键 如果中间断序 无法遍历出后面的内容for i,v in ipairs(a) do prin

2021-03-22 17:07:29 119

原创 Lua学习---------复杂数据类型table

print("***********复杂数据类型table*************")--所有的复杂类型都是table(表)print("***********数组*************")a = {1,2,3,4,"123",true,nil}--Lua中索引从1开始print(a[1])print(a[5])print(a[6])print(a[7])--#是通用的获取长度的关键字--在打印长度的时候 空被忽略了 nil意味着数组结束 哪怕nil后还有数据--如果表中(数组

2021-03-22 16:55:04 173

原创 Lua学习-------------循环

print("***********循环语句*************")print("***********while循环语句*************")num = 0--while条件 do......endwhile num <= 5 do print(num) num = num + 1endprint("***********do while循环语句*************")num = 0--repeat .......until 条件(注意:条件是结束条件)

2021-03-22 16:33:22 82

原创 Lua学习-----函数

print("****************函数****************")--function 函数名()--end--a = function()--endprint("****************无参数无返回值****************")function F1() print("F1函数")endF1()--有点类似C#中的委托和事件F2 = function() print("F2函数")endF2()print("************

2021-03-22 16:12:32 69

原创 C#比较类的大小

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace practise_1{ class Program { class Person:IComparable { public

2021-03-18 12:01:47 721

原创 抽象类和抽象方法

* **抽象类**:用关键字sbstract来修饰的类 * **特点**: * 1.不能实例化对象 * 2.抽象类中既可以写静态的成员,也可以写非静态的成员 * 3.抽象类可以被其他类继承 * **用途**: * 一种规范,用来约束所有子类的某种行为 * * **抽象方法**:用关键字abstract修饰的方法就是抽象方法 * 1.抽象方法使用abstract修饰,只有声明,没有实现 * 2.抽象方法只能写在抽象类中 * (1)如果一个非抽象类继承自一个抽象类,那么子类必须实现父.

2021-03-17 18:06:20 166

原创 C#选择冒泡排序

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Sort{ class Program { //选择排序 class SelectSort { public void sort(int[] array)

2021-03-17 18:05:12 52

原创 C#选择冒泡排序

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Sort{ class Program { //选择排序 class SelectSort { public void sort(int[] array)

2021-03-17 16:54:09 47

原创 C#ref和out的区别和例子

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace practise_1{ /* * ref是用来修饰参数的,如果一个形参用ref来修饰,那么函数中的实参也必须使用ref来修饰 * ref修饰的参数在传参的时候传递的其实是实.

2021-03-17 16:01:32 152

原创 C#二分查找

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;//二分查找namespace Seek{ class Program { static public int Seek_num(int num) { // 每次查找指定范围的中间值

2021-03-17 15:39:16 65

原创 QT窗口内嵌子页面并且多个子页面可以进行切换

QT窗口内嵌子页面并且多个子页面可以进行切换在练习使用QT制作学生管理系统的时候,就遇到了这个问题,如何使页面像浏览器一样切换自如是我遇到的一个问题。就大概是类似于上面的操作,通过点击左边的treewidget内的不同的信息,右边的区域会展示与之相关的页面。这个相关方面的我也有在网站寻找,但是其实说的感觉并没有很具体,以下的方式是我结合网上寻找的答案自己试出来的首先先创建两个界面文件,如图:其次,看一下我的例子:dialog.h#ifndef DIALOG_H#define DIALO

2021-02-03 22:17:55 15216 5

转载 聚簇索引和非聚簇索引

聚簇索引和非聚簇索引(通俗易懂 言简意赅)总结:InnoDB中,表数据文件本身就是按B+Tree组织的一个索引结构,聚簇索引就是按照每张表的主键构造一颗B+树,同时叶子节点中存放的就是整张表的行记录数据,也将聚集索引的叶子节点称为数据页。这个特性决定了索引组织表中数据也是索引的一部分;一般建表会用一个自增主键做聚簇索引,没有的话MySQL会默认创建,但是这个主键如果更改代价较高,故建表时要考虑自增ID不能频繁update这点。我们日常工作中,根据实际情况自行添加的索引都是辅助索引,辅助索引就是一个为了

2020-10-06 22:14:09 107

原创 排序算法

#include<iostream>#include<vector>using namespace std;//冒泡排序void Bubblesort(vector<int> &n){ for (int i = n.size()-1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (n[j]>n[j + 1]) { int t = n[j]; n

2020-09-18 16:39:36 78 1

原创 二维数组寻找集聚地

#include<stdio.h>int s[50][50] = { 0 };int m_n[50][50] = { 0 };int count;void fun(int x, int y, int m, int n){ if (s[x][y] == 1 || x<0 || x >= m || y<0 || y >= n || m_n[x][y] == 0) { return; } if (m_n[x][y] == 1 && s[

2020-09-14 22:16:23 103

原创 剑指offor面试题35:第一次只出现一次的字符

char FirstNotRepeatingChar(char* pString){ if (pString == NULL) { return '\0'; } const int tableSize = 256; unsigned int hashTable[tableSize]; for (unsigned int i = 0; i < tableSize; ++i) { hashTable[i] = 0; } char* pHashKey = pString;

2020-09-01 13:36:03 83

原创 剑指offor面试题34:丑数

#include<iostream>#include<stdio.h>#include<vector>using namespace std;int Min(int number1, int number2, int number3);int GetUglyNumber_Solution2(int index){ if (index <= 0) { return 0; } int *pUglyNumbers = new int[index

2020-09-01 13:19:18 674

原创 剑指offor面试题29:数组中次数超过一半的数字

bool g_bInputInvalid = false;bool CheckInvalidArray(int* numbers, int length){ g_bInputInvalid = false; if (numbers == NULL&&length <= 0) { g_bInputInvalid = true; } return g_bInputInvalid;}bool CheckMoreThanHalf(int* numbers, int

2020-08-24 17:02:00 88

原创 剑指offor面试题28:字符串的排列

void Permutation(char* pStr, char* pBegin);void Permutation(char* pStr){ if (pStr == NULL) { return; } Permutation(pStr, pStr);}void Permutation(char* pStr, char* pBegin){ if (*pBegin == '\0') { printf("%s\n", pStr); } else { for (cha.

2020-08-24 16:13:58 94

原创 在主串中寻找次串的位置和个数

void BF(char a[],char b[],int* c){ int alength = strlen(a); int blength = strlen(b); int i = 0, j = 0, k = 0;//i表示当前次串中的字符位置,j表示主串当前中的字符位置 for (int aj = 0; aj < alength; aj++) { j = aj; i = 0; while (1) { if (b[i] && b[i] == a

2020-08-20 15:18:40 99

原创 剑指offor面试题25:二叉树中和为某一值的路径

void FindPath1(BinaryTreeNode* pRoot, int sum, std::vector<int>&path, int currentSum);void FindPath(BinaryTreeNode* root,int sum){ if (root == NULL) { return; } std::vector<int> path; int currentSum = 0; FindPath1(root,sum,path,c

2020-08-20 14:19:05 102

原创 已知二叉树的前序,中序,求叶子节点的个数

int fun1(int number1[], int number2[],int length){//number1是前序,number2是中序,length是树的长度 int sum = 0; if (number1 == NULL || number2 == NULL || length <= 0) { return 0; } int root = number1[0]; if (length == 1) { return 1; } //在中序遍历中寻找roo

2020-08-19 14:49:30 359

原创 剑指offor面试题24:二叉搜索树的后序遍历序列

bool fun(int number[], int length){ if (number == NULL || length <= 0) { return false; } int root = number[length - 1]; //找到左子树的根 int i = 0; for (; i < length-1; i++) { if (number[i]>root) { break; } } //找到右子树的根 int j = i

2020-08-19 14:48:35 108

原创 剑指offor面试题20:顺时针打印矩阵

void printCircle(int** number, int col, int row, int start){ int end_x = row - 1 - start; int end_y = col - 1 - start; //从左到右打印 for (int i = 0; i < start; i++) { printf("%d ", number[start][i]); } //从上到下打印 if (end_y>start) { for (int i

2020-08-18 15:08:18 93

原创 剑指offor面试题19:二叉树的镜像

typedef struct TreeNode{ char value; TreeNode* lchild; TreeNode* rchild;}TreeNode;void MirrorRecursively(TreeNode* pNode){ if (pNode == NULL || (pNode->lchild == NULL&&pNode->rchild == NULL)) { return; } TreeNode* pTemp = pNode-

2020-08-18 14:12:36 102

原创 剑指offor面试题18:树的子结构

typedef struct TreeNode{ char value; TreeNode* lchild; TreeNode* rchild;}TreeNode;bool Tree1haveTree2(TreeNode* root1, TreeNode* root2)//判断两个子树是否相同{ /*判空的顺序一定不能变,必须是先判root2,然后判root1, 因为root2中的叶子结点可能并不是root1中的叶子结点,所以当遍历到 root2的叶子结点时,就应该回退了, */

2020-08-18 11:29:47 82

原创 剑指offor面试题17:合并两个排序的链表

typedef struct Node{ int value; Node* next;}node;Node* twoInsertList(Node* Head1, Node* Head2){ Node* Head3 = NULL; if (Head1 == NULL) { return Head2; } if (Head2 == NULL) { return Head1; }/*假设Head1 = 1 3 5 7Head2 = 2 4 6 8Head3是我们最后

2020-08-17 18:18:58 115

原创 剑指offor面试题16:反转链表

typedef struct Node{ int value; Node* next;}node; if ( Head== NULL || Head->next == NULL) { return Head; } Node *p1 = NULL, *p2 = NULL, *p3 = NULL; p1 = Head; p2 = Head->next; if (p2->next != NULL) { p3 = p2->next; } p1->

2020-08-17 15:21:20 83

空空如也

空空如也

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

TA关注的人

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