- 博客(21)
- 收藏
- 关注
转载 [滑动窗口类型]Maximum Sum Subarray of Size K
参考:https://www.cnblogs.com/grandyang/p/5336668.htmlclass Solution{public: int maxSubArrayLen(vector<int>& nums, int k) { int sum = 0, res = 0; unordered_map<int, int> m; ...
2020-04-09 21:46:37 2224
转载 Leecode刷题目录
参考知乎大神帖,在此表示感谢分享!详细回答,见以下链接。我这里只是做些笔记,方便复习。https://www.zhihu.com/question/36738189/answer/908664455类别:1. Pattern: Sliding window,滑动窗口类型2. Pattern: two points,双指针类型3. Pattern: Fast & ...
2020-04-09 12:03:28 200
翻译 Qt学习笔记4:QTreeWidget
这里是一个关于QTreeWidget使用的一个小例子,可以在这个基础上增加一些新的功能:#include "dialog.h"#include "ui_dialog.h"Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog){ ui->setupUi(this);...
2018-11-01 22:55:13 152
翻译 Qt学习笔记3:读写文件操作
#include "widget.h"#include <QFile>#include <QtCore/QCoreApplication>#include <QDebug>#include <QTextStream>#include <QString>void Write(QString Filename){ Q...
2018-10-29 22:04:03 159
翻译 Qt学习笔记2-QDir
这个例子中用到了一些Qt中文件相关的操作: #include "widget.h"#include <QFileInfo>#include <QApplication>#include <QDir>#include <QDebug>#include <QString>int main(int argc, char *...
2018-10-29 21:34:12 115
翻译 Qt学习笔记1-Basic Application and HTML Aware Widgets
前言:接下来会记录些Qt的学习笔记,笔记都是来自于Youtube上的一个教程,网址如下:https://www.youtube.com/watch?v=6KtOzh0StTc&list=PL2D1942A4688E9D63&index=1今天的内容是关于如何在Qt中使用HTML的,看以下例子:#include <QApplication>#include...
2018-10-29 20:42:14 149
翻译 C++设计模式精简版笔记
//C++常用算法和设计模式//第一课 常用排序算法#include <iostream>#include <vector>#include <time.h>#include <algorithm>#include <list>using namespace std;//mergestruct MyPrint01{...
2018-10-28 16:23:18 149
翻译 C++进阶:新人易入的那些坑 --8.杂项
/*定义:一个函数自己直接调用或间接调用自己*///P8构造和析构函数中的虚函数/*Calling Virtual Function in Constructor or Destructor*/class Dog{public: Dog() { cout << "dog born." << endl; //bark(); } virt...
2018-10-10 22:38:38 151
翻译 Learn C++11 one
// Learn C++ 11//P1:Initializer Listint arr[4] = { 3, 2, 4, 5 };vector<int> v;v.push_back(3);v.push_back(2);v.push_back(4);v.push_back(5);//C++ 11 extended the supportvector<int&g...
2018-10-10 22:32:59 123
翻译 C++进阶:新人易入的那些坑 --7.析构函数中的异常处理
/*Prevent Exceptions from Leaving Destructors*/class dog{public: string m_name; dog(string name) { m_name = name; cout << name << "is born." << endl; } ~dog() { co...
2018-09-27 22:24:16 218
翻译 C++进阶:新人易入的那些坑 --6.虚析构和智能析构函数
/*use virtual destructors in polymorphic base classes*///方案一class Dog{public: virtual ~Dog() { cout << "Dog destroyed" << endl; } virtual void bark() {}};class Yellowdog :...
2018-09-27 22:23:31 106
翻译 C++进阶:新人易入的那些坑 --5.不让编译器生成的函数
/*Compiler silently writes 4 functions if they are not explicitly declared:1.Copy constructor.2.Copy Assignment Operator.3.Destructor4.Default constructor*/class OpenFile{public: OpenFi...
2018-09-27 21:45:14 128
翻译 C++进阶:新人易入的那些坑 --4.编译器生成的函数
//########################################################################/*Compiler silently writes 4 functions if they are not explicitly declared1.Copy constructor2.Copy Assignment Operator3....
2018-09-25 22:02:30 150
翻译 C++进阶:新人易入的那些坑 --3.逻辑常量与比特位常量
class BigArray{ vector<int> v; //huge vector mutable int accessCounter;//method one int flag; int*v2;//another int arraypublic: int getItem(int index) const { accessCounter++; co...
2018-09-25 20:46:24 445
翻译 C++进阶:新人易入的那些坑2-常量和函数
//const used with functionsclass Dog{ int age; string name;public: Dog() { age = 3; name = "dummy"; } //const parameters void setAge(const int& a) { age = a;} void setAge(int& a) { a...
2018-09-25 20:25:41 99
翻译 C++进阶:新人易入的那些坑 --1.常量、常指针和指针常量
/*why use consta)Guards against inadvertent write to the variableb)Self documentingc)Enables compiler to do more optimization,making code tighter,fasterd)const means the variable can be put in R...
2018-09-24 23:14:55 84
原创 segmentation fault错误分析
一、段错误原因(1)往收到系统保护的内存地址写数据。常见的没有取数据的地址复制给指针,所以使用指针时记得初始化,使用时判断是否为NULL;(以下都是错误例子)例:int i ; int *p=i; char *k; k=null; *k='y'(2)数组越界,赋值类型不一致。(3)线程创建失败,导致pthread_join访问不存在的内存。出现段错误。
2015-02-08 18:26:26 756 4
转载 C语言中 extern "C"使用
作用:实现C++与C语言的互通性。一、标准头文件的结构#ifndef __INCvxWorksh#define __INCvxWorksh #ifdef __cplusplus /*如果采用了C++,如下代码使用C编译器;__cplusplus是cpp中的自定义宏,那么定义了这个宏的话表示这是一段cpp的代码,也就是说,上面的代码的含义是:如果这是一段cpp的代码,那么加入
2015-02-07 10:32:33 704 3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人