自定义博客皮肤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)
  • 资源 (3)
  • 收藏
  • 关注

原创 C++Thread-带返回值的线程处理函数

#include <iostream>#include <thread>#include <chrono>#include <future>using namespace std;//用asyncint returnval(){ return 100;}void test01(){ future<int> ret=async(returnval); cout << ret.get(); }//打包.

2022-03-24 23:09:10 2401 1

原创 C++创建多线程

#include <iostream>#include <thread>using namespace std;//带参函数void print(int num){ cout << "num=" << num << endl;}void test01(){ thread t1(print, 10); t1.join();}//无参函数void print2(){ cout << "无参" <&.

2022-03-21 22:47:28 599

原创 C++AVL

#include <stdio.h>#include <stdlib.h>#include <assert.h>#define HEIGHT(p) ((p==NULL)?-1:(p->height))#define MAX(a,b) ((a)>(b)?(a):(b))typedef struct { int key; char info[20];}DATA,*LPDATA;typedef struct AVLTreeNode { D.

2022-03-06 00:23:13 532

原创 C++BinarySearchTree

#include<iostream>#include<string.h>#include<string>using namespace std;class Data{public: Data() = default; Data(int key, string val):key(key),val(val){} void PrintData() { cout << this->key << " " << .

2022-03-02 00:17:08 148

原创 heap(c)

#include<stdio.h>#include<stdlib.h>#include<time.h>typedef struct{ int* mem; int cursize; int maxsize;}HEAP,*LPHEAP;LPHEAP creatheap(int maxsize){ LPHEAP newheap=(LPHEAP)malloc(sizeof(HEAP)); newheap->cursize = 0; newh.

2022-02-19 19:00:43 245

原创 数组hash

#pragma once#include<iostream>using namespace std;class hashs{public: hashs(int max) { this->maxsize = max; this->cursize = 0; this->num = new int[max]; for (int i = 0; i < max; i++) { this->num[i] = '\n'; } }.

2022-02-17 20:56:29 696

原创 BF算法(c++)

int bf(str s) { int i = 0, j = 0, index = 0; while (arr[i] != '\0' && s.arr[j]!='\0') { if (arr[i] == s.arr[j]) { i++; j++; } else { index++; i = index; j = 0; } } if (s.arr[j] == '\n') { retu..

2022-02-15 08:18:08 746

原创 自写串(c++)

#pragma once#define MAX 1024using namespace std;class str{public: str() { this->arr = new char[MAX]; for (int i = 0; i < MAX; i++) { arr[i] = '\0'; } this->cursize = 0; } void insert(int pos,const char c[]) { int n = str.

2022-02-15 07:40:41 314

原创 自写button(可扩增)

#pragma once#include<easyx.h>using namespace std;class mybutton{public: mybutton(int x1, int y1, int x2, int y2) :x1(x1), y1(y1), x2(x2), y2(y2) {} void putbutton() { solidrectangle(x1, y1, x2, y2); } const string text; int x1; int y1;.

2022-01-24 20:40:44 53

原创 C++自写stack

#pragma oncetemplate <class ty>class stack{public: stack(int num) { this->t = new ty[num]; this->max = num-1; this->top = -1; } void push(ty n) { if (this->top == this->max) return; this->t[++this->top] = n.

2022-01-18 22:10:11 508

原创 双向循环链表

#pragma onceusing namespace std;template<class ty>struct node{ node(node*pfront,ty t,node*ptail) { this->front = pfront; this->t = t; this->tail = ptail; } node() { this->front = this; this->tail = this; } node.

2022-01-17 21:58:20 382

原创 C++自写链表

#pragma once#include<iostream>using namespace std;template<class ty>struct node{ node() { this->pnext = nullptr; } node(ty t) { this->t = t; this->pnext = nullptr; } node(ty t,node* pnext) { this->t = t; thi.

2022-01-16 04:20:03 136

原创 自写顺序表

#pragma onceusing namespace std;template<class ty>class Orders{public: Orders(int max) { this->Arr = new ty[max]; this->Cursize = 0; this->Maxsize = max; } void Add(ty x); void print(); void deletes(ty x); ~Orders() { .

2022-01-11 21:26:43 222

原创 C++时间管理

头文件:chrono#include<chrono>时钟:1.system_clock(系统时钟)2.steady_clock(稳步时钟)3.high_resolution_clock(高精度时钟)三种时钟使用方法相同1.时间段的演示案例#include<iostream>#include<chrono>using namespace std;int main(){ chrono::hours(1);//1小时 chron

2022-01-06 00:23:06 1161

原创 C++智能指针和正则表达式

1.智能指针头文件:memory#include<memory>本质:一个类shared_ptr(共享形智能指针)#include<iostream>#include<memory>using namespace std;int main(){ shared_ptr<int> ps(new int(1)); }get()函数-返回对象管理的内存的指针#include<iostream>#inc

2022-01-04 21:45:58 495

原创 C++STL算法篇(下)

next_permutation:下一个排序序列的组合 #include<iostream>#include<algorithm>#include<vector>using namespace std;int main(){ vector<int> v = { 1,3,6,8,6,6,2,0,9,0 }; next_permutation(v.begin(), v.end());//下一个排序序列的组合 for (auto v..

2022-01-03 03:09:23 99

原创 C++STL容器篇(中)

list(双向链表)头文件:list创建方式如下int main(){ list<int> l;}stack(栈)头文件:stack创建方式如下int main(){ stack<int> s;}队列头文件:queue1.单向队列(queue)#include<iostream>#include<queue>using namespace std;int main(){ queue&l

2022-01-03 00:20:47 445

原创 C++STL算法篇(上)

基本查找 find:区间查找 int main(){ vector<int> v = {1,3,6,8,6,6,2,0,9,0}; vector<int>::iterator it=find(v.begin(), v.end(), 8);//区间查找 cout << *it << endl;} find_if:条件查找 int main(){ vector<int&g..

2022-01-03 00:01:15 261

原创 C++STL迭代器

1.迭代器:类中类正向迭代器只能正向不能反向#include<iostream>#include<vector>using namespace std;int main(){ vector<int> v; v.push_back(10); v.push_back(20); v.push_back(30); v.push_back(40); vector<int>::iterator it;

2021-12-28 23:27:13 353

原创 C++继承和派生

继承的基本语法:class类名:继承方式 父类,继承方式 父类......可以写多个父类,示例如下#include<iostream>using namespace std;class father{};class mother{};class son :public father, protected mother{};int main(){ return 0;}继承后,父类中的属性子类也会有一份,继承方式一共有三种:公共继承(publi

2021-12-20 22:12:01 280

原创 C++STL容器篇(三)

1.set与mulsetset(集合):数据自动去重,自动排序,默认从小到大,创建方式如下#include<iostream>#include<set>using namespace std;int main(){ set<int> s; s.insert(10); s.insert(10); s.insert(30); s.insert(20); for (set<int>::iterator it = s.begin();

2021-12-19 22:25:51 691

原创 C++类的组合

类的组合:套娃class a{public: int a;};class b{public: a p; int b;};如上,类b里有个a#include<iostream>using namespace std;class a{public: int a;};class b{public: a p; int b;};int main(){ b b1; b1.p.a = 10; return 0;}类可

2021-12-19 15:37:05 521

原创 C++运算符重载

运算符重载

2021-12-19 15:22:41 689

原创 C++容器

1.array头文件:array创建方式如下#include <iostream>#include<array>using namespace std;int main(){ array<int,3> a1; return 0;}3是数组长度,int是类型,可改,改容器为定长数组,内有许多成员函数,可以用数组的访问方式2.vector头文件:vector创建方式如下#include <iostream>

2021-12-14 23:08:03 624

原创 C++异常处理

关键字:throw try catch#include<iostream>using namespace std;int cs(int a, int b){ if (b == 0) { throw string("除数不能为0"); } return a/b;}int main(){ try { cout << cs(4, 0); } catch(string s1) { cout << s...

2021-12-13 01:01:41 229

原创 C++模板

语法:template<typename 模板名> typenamae可以用class代替1.函数模板:在函数中用模板nclude<iostream>using namespace std;template<typename t1>void print(t1 t){ cout << t << endl;}int main(){ print(520); print("hhello"); return 0;.

2021-12-12 17:16:02 443

原创 C++io流

流:数据从一段到另一段运算符:<< >>cout 标准输出#include <iostream>using namespace std;int main(){ cout << "标准输出"; return 0;}cin 标准输入#include <iostream>using namespace std;int main(){ int a = 10; cin >> ...

2021-12-07 00:09:35 622

原创 C++虚函数和多态

1.虚函数用virtual修饰的函数叫做虚函数,虚函数不论写几个都只占用4个字节,一个类,若无属性,行为则占1个字节用来占位,若写了属性,行为则不用占位了。2.虚函数表虚函数表是一个指针,4个字节,指向虚函数表int** vptr = (int **)&mm; typedef void(*PF)(); PF func = (PF)vptr[0][0]; func(); 如上是用虚函数表调用虚函数多态:子类重写父类的虚函数纯虚函数virtual void p

2021-12-06 00:12:27 663

原创 shape父类

#include<iostream>using namespace std;//设计一个类父类 Shape类 设计多个子类:Rect类 Circle类 分别求出并打印相应形状的周长和面积class shape{public: shape(int a):m_a(a) { } int m_a;};class rect :public shape{public: rect(int b,int a):m_b(b),shape(a) { } int m_b.

2021-11-29 23:08:39 787

原创 自写研究生类

#include<iostream>using namespace std;//3.设计类老师类,设计一个学生类,多继承产生一个研究生类,打印相关研究生的信息class teacher{public: teacher(int age) :m_age(age) {}; int m_age;};class student{public: student(int score) :m_score(score) {}; int m_score;};...

2021-11-29 23:07:14 138

原创 C++的特殊成员

const成员class person{public: void printc() const { cout << "hi" << endl; } int m_a;};如上,类中的函数后加了const修饰便为const的成员函数,若加了const修饰则该函数里面不能对值进行修改。若重复名,普通对象默认调用普通函数无法调用const函数,若只有const函数则普通对象可以调用const函数。const对象不能调用普通函数只能调用const修饰的函数st

2021-11-29 22:42:15 241

原创 构造函数和析构函数

构造函数:写法:类名()person(){}可以采用初始化参数列表的写法person(int a,int b):m_a(a),m_b(b){}若不写构造函数则有默认的午餐构造函数默认的无参构造函数可以用delete删除class person{public: person() = delete; int m_a;}也可以自己用default写系统默认的无参构造函数class person{public: person() = defau

2021-11-29 22:16:23 482

原创 自写Array类

#include<iostream>#include<iostream>using namespace std;class Array{public: Array(int num) :size(num) { if (num) { this->pArr = new int[num]; } } Array(const Array& a) :size(a.si...

2021-11-28 00:14:15 71

原创 C++类和对象

创建语法:classclass person{public://公共权限 void printage() { cout << m_age << endl; }void addage(int age) { m_age=age; }protected://保护权限private://私有权限 int m_age;};如上为定义类,其中public,protected,private为权限限定词,类外只可访问public作用域下,若不写则默认

2021-11-18 22:49:10 332

原创 【无标题】 C++和C的区别(二)

C++和C的区别

2021-11-16 22:43:05 327

原创 关于C++与C的区别(一)

A.头文件和空间名 1.头文件的区别 a.c语言的头文件可以省略".h"但要在前面加个c,如"stdio.h"->cstdio"#include<stdio.h>//写法1#include<cstdio>//写法2//在cpp中,可以有两种写法,c语言只能用写法1 2.空间名 a.空间的定义:namespace 空间名...

2021-11-14 17:10:57 475 1

C++推箱子(单例模式)

C++推箱子(单例模式)

2022-01-23

学生成绩管理系统(STL)版.7z

学生成绩管理系统(STL)版.7z

2021-12-25

学生成绩管理系统(链表版).rar

自己写的链表版学生成绩管理系统,注:运行时需要在exe文件的同级目录添加一个叫“管理系统.txt”的文件

2021-12-19

空空如也

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

TA关注的人

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