C++进阶编程 --- 5.STL常用算法

文章目录

    • 第五章:
      • 5.STL 常用算法
        • 5.1 遍历算法
          • 5.1.1 for_each
          • 5.1.2 transform
        • 5.2 查找算法
          • 5.2.1 find
            • 内置数据类型
            • 自定义数据类型
          • 5.2.2 find_if
            • 内置数据类型
            • 自定义数据类型
          • 5.2.3 adjacent_find
          • 5.2.4 binary_search
          • 5.2.5 count
            • 内置数据类型
            • 自定义数据类型
          • 5.2.6 count_if
            • 内置数据类型
            • 自定义数据类型
        • 5.3 排序算法
          • 5.3.1 sort
          • 5.3.2 random_shuffle
          • 5.3.3 merge
          • 5.3.4 reverse
        • 5.4 拷贝和替换算法
          • 5.4.1 copy
          • 5.4.2 replace
          • 5.4.3 replace_if
          • 5.4.4 swap
        • 5.5 算术生成算法
          • 5.5.1 accumulate
          • 5.5.2 fill
        • 5.6 集合算法
          • 5.6.1 set_intersection
          • 5.6.2 set_union
          • 5.6.3 set_difference

第五章:

5.STL 常用算法

概述:

  • 主要由algorithm functional numeric头文件组成

  • algortithm涉及到比较、交换、查找、遍历、复制等等

  • numeric体积很小,只包括几个在序列上进行简单的数学运算的模板函数

  • functional 定义了一些模板类,用于声明函数对象

5.1 遍历算法
  • for_each //遍历容器

  • transform //搬运容器到另一个容器中

5.1.1 for_each

函数原型

  • for_each(iterator beg, iterator end, __func);

    //_func 函数或者函数对象

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>//普通函数
void myPrint01(int val)
{cout << val << " ";
}//仿函数
class myPrint02
{
public:void operator()(int val){cout << val << " ";}
};void test01()
{vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}for_each(v.begin(), v.end(), myPrint01);cout << endl;for_each(v.begin(), v.end(), myPrint02());cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.1.2 transform

函数原型

  • transform(iterator beg1, iterator end1, iterator beg2, _func);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>class myTransform
{
public:int operator()(int val){return val;}
};//仿函数
class myPrint02
{
public:void operator()(int val){cout << val << " ";}
};void test01()
{vector<int>v;vector<int>aimT;for (int i = 0; i < 10; i++){v.push_back(i);}aimT.resize(v.size());transform(v.begin(), v.end(), aimT.begin(), myTransform());for_each(v.begin(), v.end(), myPrint02());cout << endl;for_each(aimT.begin(), aimT.end(), myPrint02());cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.2 查找算法
5.2.1 find

作用:查找指定元素,找到并返回指定元素的迭代器,找不到就返回结束迭代器end()

函数原型

  • find(iterator beg, iterator end, value);
内置数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>void test01()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}vector<int>::iterator it = find(v1.begin(), v1.end(), 5);if (it != v1.end()){cout << "找到元素" << *it << endl;}else{cout << "没有找到元素" << endl;}
}int main()
{test01();system("pause");return 0;
}
自定义数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class Student
{
public:Student(string name, int age){this->m_Name = name;this->m_Age = age;}bool operator==(const Student& s) //重载=={if (this->m_Name == s.m_Name && this->m_Age == s.m_Age){return true;}else{return false;}}string m_Name;int m_Age;
};void test01()
{vector<Student> v2;Student s1("小明", 18);Student s2("小红", 19);Student s3("小王", 20);v2.push_back(s1);v2.push_back(s2);v2.push_back(s3);Student f("小明", 18);vector<Student>::iterator it = find(v2.begin(), v2.end(), f);if (it != v2.end()){cout << "找到元素" << " 姓名:" << it->m_Name << " 年龄:" << it->m_Age << endl;}else{cout << "没有找到元素" << endl;}
}int main()
{test01();system("pause");return 0;
}
5.2.2 find_if

作用:按条件查找元素

函数原型

  • find_if(iterator beg, iterator end, _Pred);
    //_Pred 函数或谓词(返回bool类型的仿函数)
内置数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class ExceedFour
{
public:bool operator()(int val){return val > 4;}
};void test01()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}vector<int>::iterator it = find_if(v1.begin(), v1.end(), ExceedFour());if (it != v1.end()){cout << "找到大于4的元素" << *it << endl;}else{cout << "没有找到元素" << endl;}
}int main()
{test01();system("pause");return 0;
}
自定义数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class Student
{
public:Student(string name, int age){this->m_Name = name;this->m_Age = age;}string m_Name;int m_Age;
};class ExceedNineTeen{public:bool operator()(Student &s){return s.m_Age > 19;}};void test01()
{vector<Student> v2;Student s1("小明", 18);Student s2("小红", 19);Student s3("小王", 20);v2.push_back(s1);v2.push_back(s2);v2.push_back(s3);vector<Student>::iterator it = find_if(v2.begin(), v2.end(), ExceedNineTeen());if (it != v2.end()){cout << "找到元素" << " 姓名:" << it->m_Name << " 年龄:" << it->m_Age << endl;}else{cout << "没有找到元素" << endl;}
}int main()
{test01();system("pause");return 0;
}
5.2.3 adjacent_find

作用:查找相邻重复元素

函数原型

  • adjacent_find(iterator beg, iterator end);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void test01()
{vector<int>v;v.push_back(10);v.push_back(20);v.push_back(30);v.push_back(40);v.push_back(40);v.push_back(50);vector<int>::iterator pos = adjacent_find(v.begin(), v.end());if (pos != v.end()){cout << "找到相邻重复元素:" << *pos << endl;}else{cout << "未找到" << endl;}}int main()
{test01();system("pause");return 0;
}
5.2.4 binary_search

作用:查找指定元素是否存在

函数原型

  • bool binary_search(iterator beg, iterator end);

注意:无序序列中无法使用

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void test01()
{vector<int>v;v.push_back(1);v.push_back(2);v.push_back(3);v.push_back(4);v.push_back(5);bool ret = binary_search(v.begin(), v.end(), 4);if (ret){cout << "找到了" << endl;}else{cout << "没找到" << endl;}
}int main()
{test01();system("pause");return 0;
}
5.2.5 count

作用:统计元素个数

函数原型

  • count(iterator beg, iterator end, value);
内置数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>void test01()
{vector<int>v;v.push_back(10);v.push_back(20);v.push_back(30);v.push_back(40);v.push_back(40);int num = count(v.begin(), v.end(), 40);cout << "40的个数:" << num << endl;
}int main()
{test01();system("pause");return 0;
}
自定义数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class Student
{
public:Student(string name, int age){this->m_Age = age;this->m_Name = name;}bool operator==(const Student& s){if (this->m_Age == s.m_Age){return true;}else{return false;}}string m_Name;int m_Age;
};void test01()
{vector<Student>v;Student s1("小明", 18);Student s2("小王", 22);Student s3("小红", 19);Student s4("小李", 19);Student s5("小黑", 20);Student sf("小茂", 19);v.push_back(s1);v.push_back(s2);v.push_back(s3);v.push_back(s4);v.push_back(s5);int num = count(v.begin(), v.end(), sf);cout << "与小茂同岁的个数:" << num << endl;
}int main()
{test01();system("pause");return 0;
}
5.2.6 count_if

作用:按条件统计元素个数

函数原型

  • count_if(iterator beg, iterator end, _Pred)

    //_Pred 谓词

内置数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class ExceedThirty
{
public:bool operator()(int v){return v > 30;}
};void test01()
{vector<int>v;v.push_back(10);v.push_back(20);v.push_back(30);v.push_back(40);v.push_back(40);int num = count_if(v.begin(), v.end(), ExceedThirty());cout << "40的个数:" << num << endl;
}int main()
{test01();system("pause");return 0;
}
自定义数据类型
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>class Student
{
public:Student(string name, int age){this->m_Age = age;this->m_Name = name;}string m_Name;int m_Age;
};class ExceedNineTeen
{
public:bool operator()(const Student& s){return s.m_Age > 19;}
};void test01()
{vector<Student>v;Student s1("小明", 18);Student s2("小王", 22);Student s3("小红", 19);Student s4("小李", 19);Student s5("小黑", 20);v.push_back(s1);v.push_back(s2);v.push_back(s3);v.push_back(s4);v.push_back(s5);int num = count_if(v.begin(), v.end(), ExceedNineTeen());cout << "大于19岁的个数:" << num << endl;
}int main()
{test01();system("pause");return 0;
}
5.3 排序算法
  • sort

  • random_shuffle

  • merge

  • reverse

5.3.1 sort

作用:对容器中的元素进行排序

函数原型

  • sort(iterator beg, iterator end, _Pred);
    //按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v;v.push_back(10);v.push_back(40);v.push_back(60);v.push_back(20);v.push_back(50);v.push_back(30);//升序sort(v.begin(), v.end());for_each(v.begin(), v.end(), myPrint);cout << endl;//降序sort(v.begin(), v.end(), greater<int>());for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.3.2 random_shuffle

作用:指定范围内的元素随机调整次序

该函数也被称为洗牌函数

函数原型

  • random_shuffle(iterator beg, iterator end);
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <ctime>void myPrint(int val)
{cout << val << " ";
}void test01()
{srand((unsigned int)time(NULL));vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}random_shuffle(v.begin(), v.end());for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.3.3 merge

作用:两个容器元素合并存储到另一容器中

函数原型

  • merge(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest)

注意:两个容器必须是有序的

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;vector<int>aimV;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+3);}aimV.resize(v1.size() + v2.size());merge(v1.begin(), v1.end(), v2.begin(), v2.end(), aimV.begin());for_each(aimV.begin(), aimV.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.3.4 reverse

作用:将容器内元素进行反转

函数原型

  • reverse(iterator beg, iterator end);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}cout << "反转前:" << endl;for_each(v1.begin(), v1.end(), myPrint);cout << endl;cout << "反转后:" << endl;reverse(v1.begin(), v1.end());for_each(v1.begin(), v1.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.4 拷贝和替换算法
  • copy

  • replace

  • replace_if

  • swap

5.4.1 copy

作用:容器内指定范围的元素拷贝到另一容器中

函数原型

  • copy(iterator beg, iterator end, iterator dest);

    //按值查找元素,找到返回指定位置迭代器,找不到返回结束迭代器位置

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;for (int i = 0; i < 10; i++){v1.push_back(i);}v2.resize(v1.size());for_each(v1.begin(), v1.end(), myPrint);cout << endl;copy(v1.begin(), v1.end(), v2.begin());for_each(v2.begin(), v2.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.4.2 replace

作用:将容器内指定范围的原元素修改为新元素

函数原型

  • replace(iterator beg, iterator end, oldvalue, newvalue);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}cout << "替换前:" << endl;for_each(v1.begin(), v1.end(), myPrint);cout << endl;cout << "替换后:" << endl;replace(v1.begin(), v1.end(), 2, 20);for_each(v1.begin(), v1.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.4.3 replace_if

作用:将区间内满足条件的元素,替换为指定元素

函数原型

  • replace_if(iterator beg, iterator end, _Pred, newvalue);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}class ExceedEqualFour
{
public:bool operator()(int val){return val >= 4;}
};void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}cout << "替换前:" << endl;for_each(v1.begin(), v1.end(), myPrint);cout << endl;cout << "替换后:" << endl;replace_if(v1.begin(), v1.end(), ExceedEqualFour(), 20);  for_each(v1.begin(), v1.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.4.4 swap

作用:互换两个容器的元素

函数原型

  • swap(container c1, container c2);
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+10);}cout << "交换前:" << endl;for_each(v1.begin(), v1.end(), myPrint);cout << endl;for_each(v2.begin(), v2.end(), myPrint);cout << endl;cout << "交换后:" << endl;swap(v1, v2);for_each(v1.begin(), v1.end(), myPrint);cout << endl;for_each(v2.begin(), v2.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
{test01();system("pause");return 0;
}
5.5 算术生成算法

注意:算术生成算法属于小型算法,使用时需包含头文件numeric

  • accumulate

  • fill

5.5.1 accumulate

作用:计算区间内容器元素累计总和

函数原型

  • accumulate(iterator beg, iterator end, value);

    //value 起始值

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <numeric>void test01()
{vector<int>v1;for (int i = 0; i < 10; i++){v1.push_back(i);}int total = accumulate(v1.begin(), v1.end(), 0);cout << "total = " << total << endl;
}int main()
{test01();system("pause");return 0;
}
5.5.2 fill

作用:向容器中填充指定元素

函数原型

  • fill(iterator beg, iterator end, value)
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <numeric>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;v1.resize(10);fill(v1.begin(), v1.end(), 10);for_each(v1.begin(), v1.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
d(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}
5.6 集合算法
  • set_intersection

  • set_union

  • set_difference

5.6.1 set_intersection

作用:求两个集合的交集

函数原型

  • set_intersection(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

//dest 目标容器开始迭代器

注意:两个集合必须是有序序列

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;vector<int>aimT;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i + 3);}aimT.resize(min(v1.size(), v2.size()));cout << "v1和v2的交集为:" << endl;vector<int>::iterator itEnd = set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), aimT.begin());for_each(aimT.begin(), itEnd, myPrint);cout << endl;}int main()
{test01();system("pause");return 0;
}
5.6.2 set_union

作用:求两个集合的并集

函数原型

  • set_union(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);

//dest 目标容器开始迭代器

注意:两个集合必须是有序序列

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;vector<int>aimT;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i + 3);}aimT.resize(v1.size()+ v2.size());cout << "v1和v2的并集为:" << endl;vector<int>::iterator itEnd = set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), aimT.begin());for_each(aimT.begin(), itEnd, myPrint);cout << endl;}int main()
{test01();system("pause");return 0;
}
5.6.3 set_difference

作用:求两个集合的差集

函数原型

  • set_difference(iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);
    //dest 目标容器开始迭代器

注意:两个集合必须是有序序列,返回值是差集中最后一个元素的位置

#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>void myPrint(int val)
{cout << val << " ";
}void test01()
{vector<int>v1;vector<int>v2;vector<int>aimT;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i + 3);}aimT.resize(max(v1.size(), v2.size()));cout << "v1和v2的差集为:" << endl;vector<int>::iterator itEnd = set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), aimT.begin());for_each(aimT.begin(), itEnd, myPrint);cout << endl;cout << "v2和v1的差集为:" << endl;itEnd = set_difference(v2.begin(), v2.end(), v1.begin(), v1.end(), aimT.begin());for_each(aimT.begin(), itEnd, myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/813762.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

sed命令多行处理

1. sed 如何工作的 sed 维护两个空间&#xff1a; 模式空间保留空间 sed是以行为周期来处理文本的。 sed从输入流中读取一行&#xff0c;去掉最后的换行符&#xff0c;把它放入模式空间。随后执行命令&#xff0c;每个命令都有关联的地址和条件&#xff0c;只有匹配时才执行…

电脑端微信截图文字识别功能效率更高了

近期发现微信中的截图文字识别比QQ中的截图文字识别效率高更高&#xff0c;效果更好。 使用方法&#xff1a; 安装电脑端微信客户端&#xff1a;https://weixin.qq.com/(如果没有下载&#xff0c;可以安装一下) 默认截图组合快捷键是&#xff1a;ALTA (使用下来感觉不是很顺手…

AI在运维实践中的价值提升

在2024年的AI赛道上&#xff0c;利用大数据 、机器学习算法、人工智能来改善运维效率已成为软件运营商发展的新主张&#xff0c;通过AI在运维流程的洞察、决策和执行&#xff0c;从而提升效率、减少故障时间&#xff0c;优化用户体验。通过分析大量数据来识别趋势和模式&#x…

【MATLAB】GA_ELM神经网络时序预测算法

有意向获取代码&#xff0c;请转文末观看代码获取方式~ 1 基本定义 GA_ELM&#xff08;Genetic Algorithm and Extreme Learning Machine&#xff09;是一种结合了遗传算法和极限学习机的神经网络时序预测算法。它的核心思想是通过使用遗传算法来优化极限学习机的权重和偏差&…

Python网络爬虫中JSON格式数据存储详解

目录 一、引言 二、JSON格式数据简介 三、Python中处理JSON数据 四、网络爬虫中获取JSON数据 五、存储JSON数据到文件 六、从文件中读取JSON数据 七、注意事项和常见问题 八、总结 一、引言 在网络爬虫的应用中&#xff0c;JSON格式数据以其轻量级、易读易写的…

element UI 设置type=“textarea“ 禁止输入框缩放

背景 在 Element UI 中&#xff0c;当您使用 el-input 组件并设置 type"textarea" 时&#xff0c;默认情况下&#xff0c;用户可以通过拖动输入框的右下角来调整其大小。如果您想禁止这种缩放行为&#xff0c;需要使用 CSS 来覆盖默认的浏览器行为。 注意上图&#x…

用于显著提高检索速度和降低成本的二进制和标量嵌入量化

我们引入了嵌入量化的概念&#xff0c;并展示了它们对检索速度、内存使用、磁盘空间和成本的影响。我们将讨论理论上和实践中如何对嵌入进行量化&#xff0c;然后介绍一个 演示&#xff0c;展示了 4100 万维基百科文本的真实检索场景。 演示地址https://hf.co/spaces/sentence-…

说说你对栈、队列的理解?应用场景?

一、栈 栈&#xff08;stack&#xff09;又名堆栈&#xff0c;它是一种运算受限的线性表&#xff0c;限定仅在表尾进行插入和删除操作的线性表 表尾这一端被称为栈顶&#xff0c;相反地另一端被称为栈底&#xff0c;向栈顶插入元素被称为进栈、入栈、压栈&#xff0c;从栈顶删…

JS控制元素平滑滚动,页面自动滚动锚点实现

使用 scrollIntoView 实现元素内子元素的平滑滚动&#xff0c; 下面是模拟接口list返回&#xff0c;然后通过按钮切换下一个&#xff0c;页面就会滚动到响应的位置 具体 scrollIntoView 有一些其他参数来配置滚动的具体交换&#xff0c;网上去查即可 备注&#xff1a;下面的代码…

Element ui 动态展示表格列,动态格式化表格列的值

需求 后台配置前端展示的表格列&#xff0c;遇到比如 文件大小这样的值&#xff0c;如果后台存的是纯数字&#xff0c;需要进行格式化展示&#xff0c;并且能控制显示的小数位数&#xff0c;再比如&#xff0c;部分列值需要加单位等信息&#xff0c;此外还有状态类&#xff0…

19c ADG补丁升级及回退

一、环境说明 主 备 IP 192.168.37.201 192.168.37.202 系统版本 RedHat 7.9RedHat 7.9 数据库版本 19.3.0.0.019.3.0.0.0 SID pristd hostname primarystandby 二、OPatch配置 19c 19.22版本补丁&#xff0c;需要的Opatch的版本为12.2.0.1.40或者高于此版本才可以。 2.1…

数据结构--循环队列

1.队列的定义: 和栈相反,队列(queue)是一种先进先出(first in first out,缩写为FIFO)的线性表.它只允许在表的一端进行插入,而在另一端删除元素. 在队列中,允许插入的一端叫做队尾(rear),允许删除的一端则称为队头(front). 2.循环队列的设计图示: 3.循环队列的结构设计: ty…

很严重,大家开始存钱吧

hello大家好&#xff0c;我是张大哥&#xff0c;今天给大家聊的话题是资产和负债&#xff01;2024年&#xff0c;特别建议大家&#xff1a;一定要捂紧钱袋子&#xff0c;尽量减少不必要的消费支出&#xff0c;避免遭受经济波动的最直接影响。 什么是资产&#xff0c;就是能提供…

Vue.js npm错误:transpileDependencies.map不是一个函数

这个错误通常是由于npm版本不兼容导致的。在旧版本的npm中&#xff0c;transpileDependencies是一个字符串数组&#xff0c;我们可以直接配置需要编译的依赖库。而在较新版本的npm中&#xff0c;transpileDependencies被改成了一个对象&#xff0c;并且需要使用map()方法来处理…

刷好题,固基础-10

今天打天梯赛模拟赛有一道全排列的题&#xff08;在我看来是啦&#xff0c;虽然只拿了25/30&#xff0c;一个点超时了呜呜呜呜呜&#xff09; 在此纪念一下自己推导得出的得到两种不同全排列的方法&#xff1a; 方法一&#xff1a;按照字典序大小推导得出的全排列顺序 p是全…

【数据交换格式】网络socket编程温度采集智能存储与上报项目技术------JSON、TLV

作者简介&#xff1a; 一个平凡而乐于分享的小比特&#xff0c;中南民族大学通信工程专业研究生在读&#xff0c;研究方向无线联邦学习 擅长领域&#xff1a;驱动开发&#xff0c;嵌入式软件开发&#xff0c;BSP开发 作者主页&#xff1a;一个平凡而乐于分享的小比特的个人主页…

Git删除未跟踪的文件Untracked files

在 Git 中&#xff0c;要删除未跟踪的文件&#xff08;Untracked files&#xff09;&#xff0c;你可以使用 git clean 命令。请注意&#xff0c;这个命令会从你的工作目录中永久删除这些文件&#xff0c;因此在执行之前请确保你不再需要这些文件或已经妥善备份。 以下是如何使…

DataSource

目录 1、 DataSource 1.1、 * 建立数据库连接的参数对象 1.1.1、 * 数据库url 1.1.2、 * 数据库用户名 1.1.3、 * 数据库密码 1.1.4、 * 数据库驱动名称 <

【C++成长记】C++入门 | 类和对象(上) |面向过程和面向对象初步认识、类的引入、类的定义、类的访问限定符及封装

&#x1f40c;博主主页&#xff1a;&#x1f40c;​倔强的大蜗牛&#x1f40c;​ &#x1f4da;专栏分类&#xff1a;C❤️感谢大家点赞&#x1f44d;收藏⭐评论✍️ 一、面向过程和面向对象初步认识 C语言是面向过程的&#xff0c;关注的是过程&#xff0c;分析出求解问题的步…

C++设计模式:代理模式(十三)

1、代理模式 定义&#xff1a;为其他对象提供一种代理以控制&#xff08;隔离使用接口&#xff09;对这个对象的访问等。 动机 在面向对象系统中&#xff0c;有些对象由于某种原因&#xff08;比如对象需要进程外的访问等&#xff0c;例如在分布式的系统中&#xff09;&#x…