自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 C++ 关键字using

usingusing 作用using std::cout; // using 声明,形式: using namespace_name::name using std::cin; using namespace std; // using 指示,形式: using namespace 命名空间名/*定义别名*///*******************************...

2019-03-08 13:47:45 667

原创 this指针、inline

this 指针this 指针是一个隐含于每一个非静态成员函数中的特殊指针。它指向正在被该成员函数操作的那个对象。当对一个对象调用成员函数时,编译程序先将对象的地址赋给 this 指针,然后调用成员函数,每次成员函数存取数据成员时,由隐含使用 this 指针。当一个成员函数被调用时,自动向它传递一个隐含的参数,该参数是一个指向这个成员函数所在的对象的指针。this 指针被隐含地声明为: C...

2019-03-07 21:06:59 323

原创 隐式类型转换

隐式类型转换定义:C++ 的基本类型中并非是完全的对立,部分数据类型之间是可以进行隐式转换的。隐式转换指的是不需要用户干预,编译器私下进行的类型转换行为。很多时候用户可能都不知道发生了哪些转换。为何要进行隐式转换:C++ 面向对象的多态性,就是通过父类的类型实现对子类的封装。通过隐式转换,你可以直接将一个子类的对象使用父类的类型进行返回。…又或者数值和布尔类型的转换,整数和浮点数的转换等。...

2019-03-07 20:55:57 13267 1

原创 C++关键字知识点总结:const、volatile、static、extern、assert()、struct、typedef struct等

JoeyC++关键字:const、volatile、static、extern、assert()、struct、typedef struct等const新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数...

2019-03-04 21:05:57 814

原创 QT学习笔记

2018-10-13QT开源社区,QT基础篇学习,第1--第11篇。F1        查看帮助F2        跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2    声明和定义之间切换F4        头文件和源文件之间切换Ctrl+1         欢迎模式Ctrl+2        编辑模式Ctrl+3        调试模式Ctrl+4    ...

2018-10-13 22:01:06 102

原创 LeetCode 42. Trapping Rain Water

8ms,  71.85%.。。。从下午4点到晚9点,前两个算法思路都是错误的。第三个思路正确即先遍历数组寻找最高点,再以最高点为界,左右依次计算阶梯状的蓄水池(类似于梯田)以左侧为例,LeftTrap函数,输入的参数LeftIndex所在的柱子是从0到LeftIndex的最高柱,遍历0到LeftIndex,寻找第二高柱子NewLeftIndex,计算两者中间的水量,再递归调用Lefttra...

2018-09-20 21:22:17 111

原创 LeetCode 15. 3Sum

参考了别人的思路,效果并不好。。class Solution {public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> res; sort(nums.begin(), nums.end...

2018-09-19 18:58:35 90

原创 LeetCode 12. Integer to Roman

 44 msclass Solution {public: string dpstr(int dp, int x) { string s[4] = {"IVX", "XLC","CDM","M"}; string res; int num=0; switch(x) { c...

2018-09-19 18:57:50 86

原创 LeetCode 11. Container With Most Water

20ms,超过48%.class Solution {public: int maxArea(vector<int>& height) { int Area = 0; int L=0, R=height.size()-1; int HL=height[L], HR=height[R]; while(...

2018-09-19 11:36:22 79

原创 LeetCode 6. ZigZag Conversion

 32 ms 超过28.9%。答案里有一种做法是只申请一个string,按照i从0到numRows去遍历(即每一层遍历完再遍历下一层)class Solution {public: string convert(string s, int numRows) { if(numRows == 1) return s; int tm...

2018-09-19 10:50:02 82

原创 LeetCode 5. Longest Palindromic Substring

 100ms,超29%。。。class Solution {public: string longestPalindrome(string s) { int Aindex = 0, Alen = 0; int Bindex = 0, Blen = 0; string stra,strb; auto len = s.si...

2018-09-18 19:58:01 75

原创 LeetCode 3. Longest Substring Without Repeating Characters

顺序表存储子串,顺序检索,32ms.击败33%,待有空改进子串为hashclass Solution {public: int IsA(string a, char c) { for(int j=0; j<a.size(); j++) { if(c==a[j]) return j;...

2018-09-18 16:57:26 92

原创 LeetCode 564. Find the Closest Palindrome

 折腾了一天多,从完全自己想轮子全是bug,到借鉴别人的思路,再踩无数string的坑,算是有些收获吧。。可惜只超过了10%的人。。。。class Solution {public: string Mirror(string n) { auto len = n.size(); string res = n.substr(0,len/2); ...

2018-09-18 15:14:32 143

原创 LeetCode 8. String to Integer (atoi)

Accepted 20ms 修改while循环终止条件为不遍历完,可以到12msclass Solution {public: int myAtoi(string str) { string result; int i=0,j=0,tag=0; long long res=0; if(!((str[i]>='0'...

2018-09-16 13:46:12 83

原创 LeetCode--2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...

2018-09-15 19:11:06 85

原创 数据结构基础理论学习完成

从8月17日开始,至9月15日,时间1个月,学习数据结构基础理论,完成所有课后习题,基本实现书中所有算法的C++代码,linux平台,搭建自己习惯的vim,gdb调试。学习内容:1. 线性表:顺序存储,链表存储(单链表,循环链表,双向链表等)。2. 栈和队列:栈的定义,栈的顺序存储结构,栈的链表存储及应用;队列的顺序存储,链存储及实现。3. 串:串的定长顺序/堆/链存储...

2018-09-15 11:40:38 193

原创 动态链表实现基数排序,插入排序

#include<iostream>using namespace std;struct Node{ int key; Node *next; int yx(int i);};class ListNode{private: Node *root; int n;public: ListNode(); ~ListN...

2018-09-15 11:18:18 402

原创 顺序表存储实现冒泡排序,选择排序,插入排序,希尔排序,基数排序

#include<iostream>using namespace std;const int MAXSIZE = 100;typedef int ElemType;struct Data{ ElemType key;// int shu; int point;};//Data ar[MAXSIZE], br[MAXSIZE];int yx(...

2018-09-15 11:17:26 2590

原创 建立顺序表,实现顺序查找,折半查找,递归折半查找

#include<iostream>using namespace std;const int MAXSIZE = 100;typedef int KeyType;struct datanode{ KeyType key;// char ch;};class Sqtable{private: datanode r[MAXSIZE]; ...

2018-09-15 11:14:47 4082

原创 链地址法实现hash表,查找关键字,输出关键字

#include<iostream>using namespace std;typedef int KeyType;const int MAXSIZE = 100;struct ElemNode{ KeyType key; ElemNode *next;};class LinkHash{private: ElemNode *ht; ...

2018-09-15 11:12:57 1004 1

原创 二叉排序树查找

#include<iostream>using namespace std;typedef int KeyType;struct BstNode{ KeyType key;// char ch; BstNode *lch, *rch;};class Bstree{public: Bstree(){root = nullptr;} ...

2018-09-10 22:26:47 279

原创 矩阵存储实现图,广度优先遍历

#include<SqQueue.h>const int MaxVertices = 10;const int MaxWeight = 32767;class AdjMWGraph{private: int Vertices[MaxVertices]; int Edge[MaxVertices][MaxVertices]; int numE; ...

2018-09-04 21:56:50 476

原创 无向图,邻接链表存储,prim算法实现最小生成树,深度优先搜索,广度优先搜索。

仅实现算法过程,对输入未监测//#include<iostream>#include<SqQueue.h>#include<climits>//using namespace std;const int MaxVectices = 100;typedef int VerT;typedef int DisT;//----------------...

2018-09-04 20:01:09 929

原创 链表存储实现二叉树,实现二叉树先根,中根,后根递归非递归遍历算法

栈模板#include<iostream>using namespace std;template<class T>class SqStack{public: SqStack(int s=30); ~SqStack(){delete[] elem;} void Push(T item); T Pop(); T GetT...

2018-09-01 17:45:36 1301

原创 用十字链表示稀疏矩阵,并实现稀疏矩阵的建立,输出,加法,乘法等。

 新手学习数据结构状态,有任何问题和建议烦请指出,共同交流,谢谢~//C++ fileusing namespace std;typedef int Elemtype;struct Node{ int row; int col; Node *down; Node *right; union { Node *next...

2018-08-30 15:05:28 1353

原创 实现字符串中所有子串w用另一个字符串x来替换,w和x可以长度不同。

//C++ file#include<cstring>using namespace std;void Getnext(char s1[], int next[]){ int j=0,k=-1; next[0]=-1; int len = strlen(s1); while(j<len) { if(k==-1 ...

2018-08-30 15:04:04 237

原创 实现字符串中所有子串w用另一个字符串x来替换,w和x可以长度不同。

//C++ file#include<cstring>using namespace std;void Getnext(char s1[], int next[]){ int j=0,k=-1; next[0]=-1; int len = strlen(s1); while(j<len) { if(k==-1 ...

2018-08-30 15:03:58 363

原创 统计字符串中各字符出现的次数

//C++ file#include<vector>#include<cstring>using namespace std;int main(int argc, char *argv[]){ vector<char> s1; int ss1[20]; char test[] = "aaaabbcccdddddd"; ...

2018-08-30 15:03:15 765

原创 测试字符串是否为回文字符串

//C++ file#include<cstring>using namespace std;int main(int argc, char *argv[]){ char s1[] = "abcdedcba"; char s2[] = "aabb"; int p1 = strlen(s1); int p2 = strlen(s2); ...

2018-08-30 15:02:27 446

原创 置换字符串第pos位置开始的num个元素

//C++ file#include<cstring>#include<string.h>using namespace std;int main(int argc, char *argv[]){ char s1[] = "abcdefg"; char s2[] = "mmm"; int i,pos,num;// cout&lt...

2018-08-28 16:52:48 574

原创 字符串连接

//C++ file#include<cstring>using namespace std;int main(int argc, char *argv[]){ char s1[] = "aaa"; char s2[] = "bbb"; char *p1 = s1, *p2 =s2; int size = strlen(s1)+strlen...

2018-08-28 16:51:56 91

原创 十进制转八进制

//C++ fileusing namespace std;void trans10_8(int x){ int a = x/8; int b = x%8; if(a < 1) cout<<x; else //if(a >= 1) { cout<<b; tran...

2018-08-28 16:50:48 401

原创 链表栈:取栈顶元素和置栈空 C++实现

//C++ file#include<string>#include<string.h>using namespace std;struct Elem{ char name[10]; Elem *next;};class SqBT{private: Elem *top;public: SqBT(); ~Sq...

2018-08-28 16:50:11 1973

原创 火车调度问题

假定有编号为ABCD的4辆列车,顺序开进一个栈式结构的站台,请写出开出车站站台的列车顺序有几种 1. 假定有编号为A、B、C、D的4辆列车,顺序开进一个栈式结构的站台,请写出开出车站站台的列车顺序有几种(注释:每一列车由站台开出时均可进站,出站,但不允许出站后回退)?写出所有可能的序列。实现n列火车的调度问题//C++ file#include <vector>#inc...

2018-08-28 16:48:02 2574

原创 单链表,插入删除,连接等功能。

//C++ file#include <stdio.h>#include <iostream>#include <string>#include <string.h>using namespace std;struct ElemType { char name[10]; int tel;};struct Nod...

2018-08-28 16:45:52 122

原创 建立单链表,实现链表指定位置插入、删除,实现2个链表连接,实现Josephu问题

 建立单链表,实现链表指定位置插入、删除,实现2个链表连接,实现Josephu问题//C++ file#include <iostream>#include <string>#include <string.h>using namespace std;struct ElemType { char name[10]; int ...

2018-08-28 16:45:08 733

原创 实现顺序表逆置,在原数组上操作

//C++ file#include <stdlib.h>using namespace std;int main(int argc, char const *argv[]){ int x[5] = {1, 2, 3, 4, 5}; int len = sizeof(x); for (int i = 0; i < len; i++) ...

2018-08-28 16:43:49 1374

原创 LeetCode 707

 LeetCode 707 gdb没问题,但leetcode服务器跑出来老是不对//C++ file/*=============================================** Filename: Leetcode/7071.cpp** Author: Joe_CAO - [email protected]* Descrip...

2018-08-28 16:29:58 557

空空如也

空空如也

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

TA关注的人

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