c++学习笔记-提高篇-STL-常用六大算法(遍历、查找、排序、拷贝和替换、算术生成、集合算法)

目录

概述

一、常用遍历算法

(1)for_each

(2)transform 

二、常用查找算法

(1)find

(2)find_if

(3)adjacent_find

(4)binary_search

(5)count

(6)count_if

三、常用排序算法

(1)sort

 (2)random_shuffle

(3)reverse

(4)merge 

四、常用拷贝和替换算法

(1)copy

(2)replace

(3)replace_if

(4)swap

五、常用算数生成算法

(1)accumulate

(2)fill

六、常用集合算法

(1)set_intersection 

(2)set_union 

(3)set_difference 


概述

  • 算法主要由头文件<algorithm><functional><numeric>组成
  • <algorithm>是所有STL头文件中最大的一个,范围涉及到比较、交换、查找、遍历操作、复制、修改等
  • <numeric>体积很小,只包括几个在序列上面简单数学运算的函数模版
  • <functional>定义了一下模版类,用以声明函数对象

一、常用遍历算法

1、学习目标:掌握常用的遍历算法

2、算法简介:

  • for_each   //遍历容器
  • transform  //搬运容器到另一个容器

3、常用遍历算法

(1)for_each

  • 功能描述:实现遍历容器
  • 函数原型:

for_each(iterator beg, iterator end, _func);

//beg 开始迭代器

//end 结束迭代器

//_func 函数或者函数对象

  • 示例:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;//普通函数
void print01(int val)
{cout << val << "  ";
}//仿函数
class print02
{
public:void operator()(int val){cout << val <<"  ";}
};//常用遍历算法  for_each
void test01()
{vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}for_each(v.begin(), v.end(), print01);cout << endl;for_each(v.begin(), v.end(), print02());cout << endl;
}int main()
{test01();system("pause");return 0;
}

(2)transform 

  • 功能描述:搬运容器到另一个容器中
  • 函数原型:

transform(iterator beg1, iterator end1, iterator beg2, _func);

//beg1 源容器开始迭代器

//end1 源容器结束迭代器

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

//_func 函数或者函数对象   

可以在搬运的时候进行逻辑运算,也可以不进行逻辑运算(不进行逻辑运算时return v  就行)

  • 示例:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;//常用的遍历算法  transformclass Transform
{
public:int operator()(int v){return v + 100;}
};class myPrint
{
public:void operator()(int val){cout << val << "  ";}};
void test01()
{vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}vector<int> vTarget;//目标容器vTarget.resize(v.size());transform(v.begin(), v.end(), vTarget.begin(), Transform());for_each(v.begin(), v.end(), myPrint());cout << endl;for_each(vTarget.begin(), vTarget.end(), myPrint());cout << endl;
}int main()
{test01();system("pause");return 0;
}

注意:目标容器需要提前开辟空间

vTargrt.resize(v.size());

二、常用查找算法

1.学习目标:掌握常用的查找算法

2.算法介绍:

  • find                 //查找元素是否存在
  • find_if             //按条件查找元素
  • adjacent_find     //查找相邻重复元素
  • binary_search    //二分查找法
  • count                  //统计元素个数
  • count_if              //按条件统计元素个数

3.算法示例

(1)find

  • 功能描述:查找指定元素,找到返回指定元素的迭代器,找不到返回结束迭代器end()
  • 函数原型:

find(iterator beg,iterator end,value)

//beg开始迭代器

//end结束迭代器

//value查找的元素

  • 示例:查找  内置数据类型  和  自定义数据类型
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>//查找  内置数据类型
void test01()
{vector<int>v;for (int i = 0; i < 10; i++){v.push_back(i);}//查找容器中  是否有50 这个元素vector<int>::iterator it = find(v.begin(), v.end(), 50);if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到:" << *it << endl;;}
}class Person
{
public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}//重载  ==  底层find知道如何对比person数据类型bool operator==(const Person& p){if (this->m_Name == p.m_Name && this ->m_Age == p.m_Age){return true;}else{return false;}}string m_Name;int m_Age;};//查找  自定义数据类型
void test02()
{vector<Person>v;//创建数据Person p1("aaa", 1);Person p2("bbb", 2);Person p3("ccc", 3);Person p4("aaa", 4);//放入容器中v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);Person pp("bbb", 2);vector<Person>::iterator it = find(v.begin(), v.end(), pp);if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到:  姓名:" << it->m_Name<<"   年龄"<<it->m_Age << endl;;}
}int main()
{test01();system("pause");return 0;
}

总结:利用find可以在容器中找指定元素,返回值是迭代器

(2)find_if

  • 功能描述:按照条件查找元素
  • 函数原型:

find_if(iterator beg, iterator end, _Pred);

//beg开始迭代器

//end结束迭代器

//_Pred函数或者谓词(返回bool类型的仿函数)

  • 示例:
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>//find_if查找 内置数据类型class GreatFive
{
public:bool operator()(int val){return val > 5;}
};
void test01()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}vector<int>::iterator it = find_if(v.begin(), v.end(), GreatFive());if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到大于五的数为:" << *it << endl;}
}//find_if查找 自定义数据类型
class Person
{
public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}string m_Name;int m_Age;
};class Great20
{
public:bool operator()(Person &p){return p.m_Age > 20;}
};
void test02()
{vector<Person> v;//创建数据Person p1("aaa", 10);Person p2("bbb", 20);Person p3("ccc", 30);Person p4("ddd", 40);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);//找年龄大于20的人vector<Person>::iterator it = find_if(v.begin(), v.end(), Great20());if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到年龄大于20 :    姓名:" << it->m_Name << "  年龄:" << it->m_Age << endl;;}
}int main()
{//test01();test02();system("pause");return 0;}

(3)adjacent_find

  • 功能描述:查找相邻元素,返回相邻元素的第一个位置的迭代器
  • 函数原型:

adjacent_find(iterator beg, iterator end);

//beg开始迭代器

//end结束迭代器

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;void test01()
{vector<int> v;v.push_back(0);v.push_back(2);v.push_back(0);v.push_back(4);v.push_back(1);v.push_back(4);v.push_back(1);v.push_back(3);vector<int>::iterator pos = adjacent_find(v.begin(), v.end());if (pos == v.end()){cout << "未找到相邻元素" << endl;}else{cout << "找到相邻元素: "<<*pos << endl;}
}int main()
{test01();system("pause");return 0;
}
  • 功能描述:查找指定元素是否存在,返回bool值(查到返回true,否则false)
  • 函数原型:

bool binary_search(iterator beg, iterator end, value)

//注意:在无序序列中不可用

//beg开始迭代器

//end结束迭代器

//value查找的元素

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;void test01()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}//查找容器中是否有9  元素//v.push_back(2);//如果加入2后变无序序列,结果未知//注意:容器必须是有序序列bool ret = binary_search(v.begin(), v.end(), 9);if (ret){cout << "找到元素" << endl;}else{cout << "未找到元素" << endl;}}int main()
{test01();system("pause");return 0;
}

(5)count

  • 功能描述:统计元素出现次数
  • 函数原型:

count(iterator beg, iterator end, value)

//beg开始迭代器

//end结束迭代器

//value统计的元素

  • 示例:
#include<iostream>
#include<vector>
using namespace std;
#include<algorithm>//统计  内置数据类型
void test01()
{vector<int>v;v.push_back(10);v.push_back(40);v.push_back(30);v.push_back(40);v.push_back(20);v.push_back(40);int num = count(v.begin(), v.end(), 40);cout << "40的元素个数为: " << num << endl;
}//统计  自定义数据类型
class Person
{
public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}bool operator==(const Person& p)//重载了“==”{if (this->m_Age == p.m_Age)  //这里可以更改条件{return true;}else{return false;}}string m_Name;int m_Age;    
};void test02()
{vector<Person> v;Person p1("a", 10);Person p2("b", 20);Person p3("c", 30);Person p4("d", 40);Person p5("d", 30);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);Person p("e", 50);//查找和p相同30岁的人int num = count(v.begin(), v.end(), p);if (num){cout << "和e同岁的人有:" << num << endl;}else{cout << "无和e同岁的人" << endl;}}int main()
{//test01();test02();system("pause");return 0;
}

(6)count_if

  • 功能描述:按照条件统计元素个数
  • 函数原型:

coynt_if(iterator beg, iterator end, _Pred)

//beg开始迭代器

//end结束迭代器

//_Pred谓词

  • 示例:
#include<iostream>
#include<vector>
using namespace std;
#include<algorithm>//常用查找算法 count_if
//统计  内置数据类型
class Great30
{
public:bool operator()(int val){return val > 30;}
};void test01()
{vector<int> v;v.push_back(10);	v.push_back(40);v.push_back(30);v.push_back(40);v.push_back(40);int num = count_if(v.begin(), v.end(), Great30());if (num){cout << "大于30的数有:" << num << "个" << endl;}else{cout << "无大于30的数" << endl;}}//统计  自定义数据类型
class Person
{
public:Person(string name, int age){this->m_Name = name;this->m_Age = age;}string m_Name;int m_Age;
};class AgeGreat20
{
public:bool operator()(const Person &p1){return p1.m_Age > 20;}
};void test02()
{vector<Person>v;Person p1("aaa", 10);Person p2("bbb", 20);Person p3("ccc", 30);Person p4("ddd", 40);Person p5("eee", 30);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);int num = count_if(v.begin(), v.end(), AgeGreat20());cout << "大于20人员的个数为:" << num << endl;
}int main()
{//test01();test02();system("pause");return 0;
}

三、常用排序算法

常用的排序算法

  • sort                          //对容器内元素进行排序
  • random_shuffle       //洗牌,指定范围内的元素随机调整次序
  • merge                     //容器元素合并,并存储到另一容器
  • reverse                   //反转指定范围的元素

(1)sort

  • 功能描述:对容器内元素进行排序
  • 函数原型:

sort(iterator beg, iterator end, _Pred)

//beg开始迭代器

//end结束迭代器

//_Pred谓词,默认从小到大,可以改变排序规则

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用排序算法 sort
void myPrint(int val)
{cout << val << "  ";
}void test01()
{vector<int> v;v.push_back(10);v.push_back(30);v.push_back(20);v.push_back(50);v.push_back(40);//利用sort进行升序排序sort(v.begin(), v.end());for_each(v.begin(), v.end(),myPrint);cout << endl;//改变  降序排序sort(v.begin(), v.end(), greater<int>());//greater<int>()是内置函数for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}

 (2)random_shuffle

  • 功能描述:洗牌,指定范围内的元素随机调整次序
  • 函数原型:

random_shuffle(iterator beg, iterator end)

//beg开始迭代器

//end结束迭代器

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<ctime>void myPrint(int val)
{cout<<val<<" ";
}
void test01()
{srand((unsigned)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;
}

 总结:记得加上随机数种子srand((unsigned)time(NULL)),才能模拟真实的随机

(3)reverse

  • 功能描述:将容器内元素进行反转
  • 函数原型:

reverse(iterator beg, iterator end);

//beg开始迭代器

//end结束迭代器

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用排序算法 reversevoid myPrint(int val)
{cout << val << "  ";
}
void test01()
{vector<int>v;v.push_back(10);v.push_back(20);v.push_back(40);v.push_back(30);v.push_back(50);v.push_back(80);cout << "反转前:" << endl;for_each(v.begin(), v.end(), myPrint);cout << endl;cout << "反转后:" << endl;reverse(v.begin(),v.end());for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}

(4)merge 

  • 功能描述: 两个容器元素合并,并存储到另一容器中 两个容器元素必须是有序的,都是同样顺序的,不能一个升序一个降序,而且合并之后的新容器也是有序的
  • 函数原型: merge (iterator beg1, iterator end1, iterator beg2, iterator end2, iterator dest);
  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;void myPrint(int val)
{cout << val << "  ";
}void test01()
{//first 和 second 数组中各存有 1 个有序序列int first[] = { 5,10,15,20,25 };int second[] = { 7,17,27,37,47,57 };//用于存储新的有序序列vector<int> myvector(11);//将 [first,first+5) 和 [second,second+6) 合并为 1 个有序序列,并存储到myvector容器中。merge(first, first + 5, second, second + 6, myvector.begin());//输出 myvector 容器中存储的元素for_each(myvector.begin(), myvector.end(), myPrint);cout << endl;	
}int main()
{test01();system("pause");return 0;
}

四、常用拷贝和替换算法

常用拷贝和替换算法

  • copy()             //容器内指定范围的元素拷贝到另一个容器中
  • replace()         //容器内指定范围的旧元素修改为新元素
  • replace_if()     //容器内指定范围满足条件的元素替换为新元素
  • swap()            //互换两个容器元素

(1)copy

  • 功能描述:容器内指定范围的元素拷贝到另一个容器中
  • 函数原型:

copy(iterator beg, iterator end, iterator dest)

//beg开始迭代器

//end结束迭代器

//dest目标起始迭代器

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用的拷贝和替换算法 copy
void myPrint(int val)
{cout << val << "  ";
}
void test01()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}vector<int> v2;v2.resize(v1.size());copy(v1.begin(), v1.end(), v2.begin());//等价于使用  v2=v1for_each(v2.begin(), v2.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}

总结:在利用copy算法进行拷贝时,目标容器记得提前开辟空间 

(2)replace

  • 功能描述:容器内指定范围的旧元素修改为新元素
  • 函数原型:

replace(iterator beg, iterator end, oldvalue,newvalue)

//beg开始迭代器

//end结束迭代器

//oldvalue旧元素

//newvalue新元素

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用的拷贝和替换算法 replace//仿函数
class myPrint
{
public:void operator()(int val){cout << val << "  ";}
};void test01()
{vector<int> v;v.push_back(20);v.push_back(30);v.push_back(20);v.push_back(50);v.push_back(10);v.push_back(30); v.push_back(100);v.push_back(30);cout << "替换前:" << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;cout << "替换后:" << endl;//将20替换为2000replace(v.begin(), v.end(), 20, 2000);for_each(v.begin(), v.end(), myPrint());cout << endl;
}int main()
{test01();system("pause");return 0;
}

总结:replace会替换区间内索引满足条件的元素

(3)replace_if

  • 功能描述:容器内指定范围满足条件的元素替换为新元素
  • 函数原型:

replace(iterator beg, iterator end, _Pred, newvalue)

//beg开始迭代器

//end结束迭代器

//_Pred谓词

//newvalue旧元素

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用的拷贝和替换算法 replace_if
class myPrint
{
public:void operator()(int val){cout << val << "  ";}
};class great30 //仿函数
{
public:bool operator()(int val){return val >= 30;}
};void test01()
{vector<int> v;v.push_back(20);v.push_back(30);v.push_back(50);v.push_back(50);v.push_back(30);v.push_back(10);v.push_back(10);v.push_back(60);v.push_back(10);v.push_back(30);cout << "替换前:" << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;//将大于等于30  替换为3000replace_if(v.begin(), v.end(), great30(), 3000);cout << "替换后:" << endl;for_each(v.begin(), v.end(), myPrint());cout << endl;}int main()
{test01();system("pause");return 0;
}

(4)swap

  • 功能描述:互换两个容器元素
  • 函数原型:

swap(container c1,container c2);

//c1容器

//c2容器

  • 示例:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;//常用拷贝和替换算法  swap
class myPrint
{
public:void operator()(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(100 + i);}cout << "交换前:" << endl;for_each(v1.begin(), v1.end(), myPrint());cout << endl;for_each(v2.begin(), v2.end(), myPrint());cout << endl;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;
}

 总结:swap交换容器时,注意交换的容器要同种类型

五、常用算数生成算法

常用的算数生成算法

  • accumulate            //计算容器元素累计总和
  • fill                           //向容器中添加元素

注意:算术生成算法属于小型算法,使用时包含头文件为#include<numeric>

(1)accumulate

  • 功能描述:计算区间内 容器元素累计和
  • 函数原型:

accumulate(iterator beg, iterator end, value)

//beg开始迭代器

//end结束迭代器

//起始的累加值

  • 示例:
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;//常用算术生成算法int main()
{vector<int>v;for (int i = 0; i < 101; i++){v.push_back(i);}int total = accumulate(v.begin(), v.end(), 0);//参数3是起始的累加值cout << "total = " << total << endl;system("pause");return 0;
}

(2)fill

  • 功能描述:向容器中填充指定的元素
  • 函数原型:

fill(iterator beg, iterator end, value)

//beg开始迭代器

//end结束迭代器

//起始的累加值

  • 示例:
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;void myPrint(int val)
{cout << val << "   ";
}//常用算术生成算法  fill
void test01()
{vector<int> v;v.resize(10);//后期重新填充fill(v.begin(), v.end(), 100);for_each(v.begin(), v.end(), myPrint);cout << endl;
}int main()
{test01();system("pause");return 0;
}

六、常用集合算法

常用的集合算法:

  • set_intersection          //求两个容器的交集
  • set_union                   //求两个容器的并集 
  • set_difference            //求两个容器的差集

(1)set_intersection 

功能描述:求两个容器的交集

函数原型:

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

//beg1容器1开始迭代器

//end1容器1结束迭代器

//beg2容器2开始迭代器

//end2容器2结束迭代器

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

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

示例:

#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;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);//0~9v2.push_back(i+5);//5~14}vector<int> vTarget;//目标容器需要提前开辟空间//最特殊的情况   大容器包含小容器//开辟空间  取小容器的size即可vTarget.resize(min(v1.size(), v2.size()));vector<int>::iterator itEnd = set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());for_each(vTarget.begin(), itEnd , myPrint);cout << endl;}int main()
{test01();system("pause");return 0;
}

总结:

  • 求交集的两个集合必须是有序序列
  • 目标容器开辟空间需要从两个容器中取较小size 
  • set_intersection返回值是交集中最后一个元素的位置

(2)set_union 

  • 功能描述:求两个容器的并集
  • 函数原型:

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

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

//beg1容器1开始迭代器

//end1容器1结束迭代器

//beg2容器2开始迭代器

//end2容器2结束迭代器

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

  • 示例:
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;class myPrint
{
public:void operator()(int val){cout << val << "  ";}
};//常用集合算法  set_union
void test01()
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i + 5);}vector<int>vTarget;//目标容器要提前开辟空间//最特殊的情况  两个容器没有交集,并集就是两个容器size相加vTarget.resize(v1.size() + v2.size());vector<int>::iterator itEnd = set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());for_each(vTarget.begin(), itEnd , myPrint());cout << endl;
}int main()
{test01();system("pause");return 0;
}
  • 求并集的两个集合必须是有序序列
  • 目标容器开辟空间需要从两个容器相加
  • set_union返回值是并集中最后一个元素的位置

(3)set_difference 

  • 功能描述:求两个集合的差集
  • 函数原型:

set_difference(iterator beg1, iterator end1,iterator beg2, iterator end2, terator dest)

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

//beg1容器1开始迭代器

//end1容器1结束迭代器

//beg2容器2开始迭代器

//end2容器2结束迭代器

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

  • 示例:
#include<iostream>
#include<vector>
#include<numeric>
#include <algorithm>
using namespace std;class myPrint
{
public:void operator()(int val){cout << val << "  ";}
};//常用集合算法  set_difference
void test01()
{vector<int>v1;vector<int>v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i + 5);}//创建目标容器vector<int>vTarget;//给目标容器开辟空间//最特殊情况  两个容器没有交集,取两个容器中大的size作为目标容器开辟空间vTarget.resize(max(v1.size(), v2.size()));cout << "v1与v2的差集为:" << endl;vector<int>::iterator itEnd = set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), vTarget.begin());for_each(vTarget.begin(), itEnd, myPrint());cout << endl;cout << "———————————————————————————" << endl;cout << "v2与v1的差集为:" << endl;vector<int>::iterator itEnd1 = set_difference(v2.begin(), v2.end(), v1.begin(), v1.end(), vTarget.begin());for_each(vTarget.begin(), itEnd1, myPrint());cout << endl;
}int main()
{test01();system("pause");return 0;}
  • 求差集的两个集合必须是有序序列
  • 目标容器开辟空间需要从两个容器取较大
  • set_union返回值是差集中最后一个元素的位置

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

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

相关文章

RTT打印时间戳

官方的RTT VIEWER没有打印接收时间戳的功能&#xff0c;经过查找后发现可以有以下三种打印时间戳的方法。 第三方的RTT上位机ExtraPutty自己打印 第三方的RTT上位机 码云上有一个RTT_T2的仓库&#xff0c;基于python qt包写的画面&#xff0c;通过pylink来jlink通信。 优点…

Journal of King Saud University - Computer and Information Sciences投稿经验

期刊标签&#xff1a; 中科院二区 JCR Q1 影响因子&#xff1a;6.9 双盲审 个人认为还是很不错的期刊 开源期刊1350美元版面费 投稿经验 一共三个审稿人&#xff0c;一个建议小修后录取&#xff08;list文章的贡献&#xff0c;添加一篇文章的引用&#xff09;&#xff0c; 另…

conda创建、查看、删除虚拟环境

在现代的Python开发中&#xff0c;使用虚拟环境已经成为了一种标准的做法。它可以帮助我们隔离不同的项目&#xff0c;使得每个项目都有自己独立的Python环境和依赖&#xff0c;从而避免各种依赖冲突。Conda是一个流行的包管理器和环境管理器&#xff0c;它可以帮助我们轻松地创…

Java八股文面试全套真题【含答案】-SQL优化篇

以下是关于Java八股文面试全套真题-SQL优化篇 你SQL优化这块有哪些技巧和方法&#xff0c;谈一谈&#xff1f; 以下是一些常用的SQL优化技巧&#xff1a; 使用索引&#xff1a;索引是提高SQL查询性能的最常见和有效的方法之一。通过创建适当的索引&#xff0c;可以加快查询的…

Nginx 负载均衡集群 节点健康检查

前言 正常情况下&#xff0c;nginx 做反向代理负载均衡的话&#xff0c;如果后端节点服务器宕掉的话&#xff0c;nginx 默认是不能把这台服务器踢出 upstream 负载集群的&#xff0c;所以还会有请求转发到后端的这台服务器上面&#xff0c;这样势必造成网站访问故障 注&#x…

Linux GDB 调试

文章目录 一、Qemu二、Gdbvscode 调试 三、RootFs 一、Qemu qemu 虚拟机 Linux内核学习 Linux 内核调试 一&#xff1a;概述 Linux 内核调试 二&#xff1a;ubuntu20.04安装qemu Linux 内核调试 三&#xff1a;《QEMU ARM guest support》翻译 Linux 内核调试 四&#xff1a;…

基于SSM框架和Layui框架的管理系统

计算机毕业设计&#xff1a;打造安全、高效的信息管理系统在这个数字化时代&#xff0c;信息安全和高效管理是至关重要的。为了帮助学校或机构更好地管理和保护信息&#xff0c;我们为您设计了一套功能强大的信息管理系统。该系统利用先进的技术&#xff0c;结合MD5加密&#x…

使用Go语言的HTTP客户端进行并发请求

Go语言是一种高性能、简洁的编程语言&#xff0c;它非常适合用于构建并发密集型的网络应用。在Go中&#xff0c;标准库提供了强大的HTTP客户端和服务器功能&#xff0c;使得并发HTTP请求变得简单而高效。 首先&#xff0c;让我们了解为什么需要并发HTTP请求。在许多应用场景中…

【Nacos专题】Nacos如何建立与应用服务之间的通信渠道?

作为Spring Cloud Alibaba微服务架构实战派上下册和RocketMQ消息中间件实战派上下册的作者胡弦。 Nacos是一款面向云原生服务的注册中心和配置中心技术解决方案&#xff0c;既然要与服务打交道&#xff0c;那么通信渠道是必不可少的组件&#xff0c;那么Nacos是如何建立与应用…

【后端已完成,前端更新ing】uniapp+springboot实现个人备忘录系统【前后端分离】

目录 &#xff08;1&#xff09;项目可行性分析 &#xff08;一&#xff09;技术可行性&#xff1a; &#xff08;二&#xff09;经济可行性&#xff1a; &#xff08;三&#xff09;社会可行性&#xff1a; &#xff08;2&#xff09;需求描述 功能模块图 用例图&#…

Xcode15在iOS12系统上崩溃的原因

1.1.崩溃在_dyld_start&#xff0c;如图&#xff1a; 崩溃截图 解决办法&#xff1a;在other link flags添加-ld64 注意&#xff1a;该办法只能解决运行真机&#xff0c;archive出来的包依然报错闪退...... 1.2 SwiftUI导致iOS12及以下系统闪退问题 SwiftUI是iOS13开始使用&…

(NeRF学习)NeRF复现 win11

目录 一、获取源码二、环境三、准备数据集1.下载数据集方法一&#xff1a;官方命令方法二&#xff1a;官网下载数据集 2.修改配置 四、开始训练1.更改迭代次数2.开始训练方法一&#xff1a;方法二&#xff1a; 3.使用预训练模型 五、NeRF源码学习 一、获取源码 git clone http…

Blazor 问题记录

1&#xff09;使用Ant 样式。结果弹窗提示怎么都出不来。 只要在App.razor 加最后一句即可 <Router AppAssembly"typeof(App).Assembly"><Found Context"routeData"><RouteView RouteData"routeData" DefaultLayout"typeof…

C#之反编译之路(一)

本文将介绍微软反编译神器dnSpy的使用方法 c#反编译之路(一) dnSpy.exe区分64位和32位,所以32位的程序,就用32位的反编译工具打开,64位的程序,就用64位的反编译工具打开(个人觉得32位的程序偏多,如果不知道是32位还是64位,就先用32位的打开试试) 目前只接触到wpf和winform的桌…

什么是负载均衡?什么情况下又会用到负载均衡

什么是负载均衡 在大型的网络应用中&#xff0c;使用多台服务器提供同一个服务是常有的事。平均分配每台服务器上的压力、将压力分散的方法就叫做负载均衡。 [利用 DNS来实现服务器流量的负载均衡&#xff0c;原理是“给网站访问者随机分配不同ip”] 什么情况下会用到负载均…

芯课堂 | LVGL基础知识(三)

概述 LVGL进度条对象上有一个背景和一个指示器。指示器的宽度根据进度条的当前值进行设置。 如果对象的宽度小于其高度&#xff0c;则可以创建垂直进度条。 不仅可以设置进度条的结束值&#xff0c;还可以设置进度条的起始值&#xff0c;从而改变指示器的起始位置。 LVGL进度…

使用EasyExcel导出百万条数据

使用EasyExcel导出百万条数据 应用是基于100W条数据进行的测试 首先&#xff1a;导入相关需要的依赖&#xff1a; <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.16</version></depend…

jquery获取子元素的一些方法

jquery获取子元素的一些方法 1.通过id,class等选择器 2.通过父元素进行find查找 3.通过父元素的children进行查找 注意:find和children的区别,代码已给出详细解释,想要真正理解,还是得靠代码.光看不练那都是纸上谈兵 <!DOCTYPE html> <html><head><m…

springboot系列——IDEA创建项目并运行

springboot Spring Boot是为了简化Spring应用程序的开发和部署而产生的。 Spring Boot提供了一种基于约定优于配置的开发模式。它自动配置了Spring应用程序所需的各种组件和依赖&#xff0c;并提供了简单易用的命令行工具来构建和运行应用程序。 Spring Boot还提供了一套开箱…

Existing installation is up to date

这个报错是之前安装的docker没有删除干净 解决方法&#xff1a; 打开注册表编辑器 然后再搜索栏&#xff1a;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Docker Desktop 回车 找到Docker Desktop文件夹后&#xff0c;右键删除 重新安装Docker…