自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 queue队容器 输出通过重载输出流运算符输出

#include<iostream> using namespace std; #include<queue> class person { public: person(string name, int age) { this->m_name = name; this->m_age = age; } string m_name; int m_age; }; //重载输出流运算符对queue容器进行输出 ostream& operator&

2021-06-02 20:44:12 104

原创 队列容器 queue容器

#include<iostream> using namespace std; #include<queue> class person { public: person(string name, int age) { this->m_name = name; this->m_age = age; } string m_name; int m_age; }; //ostream operator<<(person& p) //{ //

2021-06-02 20:21:28 88

原创 stack 栈容器的使用 满足的 数据结构是先进后出

#include<iostream> using namespace std; #include<stack> void test01() { //创建一个stack容器 stack<int>s; //入栈 s.push(0); s.push(10); s.push(20); s.push(30); cout << "栈的大小:" << s.size() << endl; ;// 栈满足先进后出 先放进去的元素在栈的底部

2021-06-02 19:18:01 139 1

原创 有五名歌唱选手参加比赛,共有十个评委对其打分 去掉其中最高分和最低分 利用随机数对其打分 并且输出得分最高者

#include<iostream> using namespace std; #include<vector> #include<string> #include<algorithm> #include<deque> #include<ctime> //评委打分案例 //有五名歌唱选手参加比赛,共有十个评委对其打分 去掉其中最高分和最低分 获取其均值 均值大的人获胜 class person { public: //构造函数 .

2021-06-01 21:26:29 1099

原创 deque容器 用法(ps:基本语法跟vector一样)

deque容器跟vector容器的区别:deque容器是双端容器 不存在容量大小 !(https://img-blog.csdnimg.cn/20210525203521679.png) #include<iostream> using namespace std; #include<deque> #include<algorithm> //deque容器跟vector容器差不多 deque容器是一个队列结构 void printdeque(const deque&

2021-05-25 20:35:41 67

原创 vector容器的用法

#include<iostream> using namespace std; //vector容器初识 vector相当于一个数组容器 #include<vector> #include<string> //创建一个vecto容器 void test01() { vector<int> v; //向容器中插入数据 v.push_back(10); v.push_back(20); v.push_back(30); v.push_back(40);

2021-05-24 21:03:02 275

原创 string容器的使用方法

#include<iostream> using namespace std; #include<string> #include<string> //string容器的赋值 //string容器的补长 通过+=实现 void test01() { string str1 = "zhang"; str1 += "xiang"; cout << str1 << endl; string str2; str2.assign("pppp

2021-05-20 20:31:44 81

原创 职工管理系统之添加职工

//workermanager.h #pragma once//防止头文件重复使用 #include<iostream> #include"worker0.h" #include"manager.h" #include"boss.h" #include"employ.h" using namespace std; class workermanger { public: //workermanger();//构造函数 ~workermanger();//析构函数 void exitsys

2021-05-18 20:18:42 260 2

原创 计算机运行(多态语法总结)

//多态语法总结 父类指针指向子类成员 子类成员重写父类虚函数 #include <iostream> using namespace std; //cpu基类 class cpu { public:virtual void calculate() = 0; }; //显卡基类 class videocard { public:virtual void display() = 0; }; //内存条基类 class memory { public:virtual void storage()

2021-04-29 20:23:05 68

原创 自制简单计算器

//写一个计算器 //注释的部分为不是自定义输入数据时的计算器 #include<iostream> using namespace std; #include<string> class calculator { public: void printin(); /*void printout();*/ friend void test01(); float getrusult(string oper); private:float a; float b; float s

2021-04-27 20:33:14 118

原创 计算平方

#include<iostream> using namespace std; int main() { //a代表我输入的数 int a; cin >> a; //i表示循环 i且代表数的指数 通过这个我能求某个数的某个次方 for (int i = 1; i < 20; i++) { //static为静态变量 初值为1,第一次之后变成2,不会释放 static long sum = 1; // static long sum=2;第二次循环后

2021-04-27 20:31:42 54

原创 n的全排列

//n的全排列 #include<iostream> using namespace std; const int s = 10;//全排列的收纳盒 int n; int arr[s]; int hashtable[s] = { false };//整型数组 与布尔数组相互转化 void GE(int index) { //跳出循环的条件 //递归求全排列 for (int x = 1; x <= n; x++) { if (hashtable[x] == false)//第一个

2021-04-27 20:31:02 130

原创 重载加号运算符使其能进行矩阵相加

//重载+号运算符 使其两个矩阵相加 //矩阵的输入输出都需要使用for循环 行和列的循环 #include<iostream> using namespace std; class mix { public: friend mix operator+(mix&, mix&); void printin(); void printout(); private: int arr[2][3]; }; //输入数据 void mix::printin() { cout &lt

2021-04-27 20:30:07 521 1

原创 商品售价问题

#include<iostream> using namespace std; class shop { public: shop(char n, int q, int p) :num(n), quantity(q), price(p) {}; friend float sum(shop& s); private: char num; int quantity; int price; }; float sum(shop& s) { int sum = 0; if (

2021-04-27 20:29:01 155

原创 运算符的重载

#include<iostream> using namespace std; class integer { public: friend ostream& operator<<(ostream& cout, integer myint); //重载自增运算符++a integer& operator++()//为什么返回的是引用 引用的好处形成链接 为了一直对一个数据进行递增 { m_a++; return *this; } //重载

2021-04-27 20:28:20 34

原创 判断点与圆的位置关系

#include<iostream> using namespace std; //创建一个点类 class point {public: //设置点的坐标 void setm_x(int x) { m_x = x; } //获得点的坐标 int getm_x() {return m_x; } void setm_y(int y) { m_y = y; } //获得点的坐标 int getm_y() { return m_y; } private: //

2021-04-27 20:27:38 674

原创 分别用引用和指针指向多态的子类成员

//多态实现一个饮料制作 //n的全排列 #include<iostream> using namespace std; class abstract { public:virtual void makedrinking() = 0; }; class makecoffee :public abstract { public: virtual void makedrinking() { cout << "第一步:烧水" << endl; cout <&l

2021-04-27 19:53:00 53

原创 多态实现编写一个计算器

//多态实现一个计算器 //多态实现计算器的好处 //1.不用改动源码 //2.只需对源码进行扩充或删除 不需要改动 //3.多态的实习语法 //父类的指针或引用指向子类的函数 //base *s=new 子类名 //通过s->访问子类的成员和子类的函数 //用完记得销毁new栈区的内存 防止内存泄漏 #include<iostream> using namespace std; #include<string> #include<cmath> class Abst

2021-04-26 21:23:07 617

空空如也

空空如也

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

TA关注的人

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