当前位置: 首页 > article >正文

STL常用算法——C++

1.概述

2.常用遍历算法

1.简介

2.for_each

方式一:传入普通函数(printf1)

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void printf1(int a)
{cout << a << " ";
}
int main()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}for_each(v.begin(), v.end(), printf1);cout << endl;return 0;
}

方式2:利用仿函数,传入匿名函数对象

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class person
{
public:void operator()(int a){cout << a << " ";}
};
int main()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}for_each(v.begin(), v.end(), person());cout << endl;return 0;
}

注意:函数只需要传入函数名就行,但是仿函数需要传入函数对象。

for_each在实际开发中是最常用的一个算法,需要熟练掌握

3.transform

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class transform1
{
public:int operator()(int a){return a;}
};
class print
{
public:void operator()(int a){cout<<a<<" ";}
};
int main()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}vector<int>v1;v1.resize(v.size());transform(v.begin(), v.end(), v1.begin(), transform1());for_each(v.begin(), v.end(), print());cout << endl;return 0;
}

注意:转运之前,需要将目标对象用resize()也开辟相同的空间。

3.常用查找算法

1.find

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class person
{
public:person(string name, int age){this->name = name;this->age = age;}bool operator==(const person& p){if (this->age == p.age && this->name == p.name){return true;}else return false;}string name;int age;
};
int main()
{vector<person> v;person p1("1", 12);person p2("2", 13);person p3("3", 14);person p4("4", 15);person p5("5", 16);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);vector<person>::iterator it = find(v.begin(), v.end(), p2);if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到了" << endl;}return 0;
}

或者也可以将查找条件改为

    person pp(”11“,13);

    vector<person>::iterator it = find(v.begin(), v.end(), pp);

注意:find的返回值是迭代器

2.find_if

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v;for (int i = 0; i < 10; i++){v.push_back(i);}vector<int>::iterator it=find_if(v.begin(), v.end(), person());if (it == v.begin()){cout << "没有找到" << endl;}else{cout << "找到了:" << *it << endl;}return 0;
}

3.abjacent_find

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
int main()
{vector<int> v;v.push_back(1);v.push_back(1);v.push_back(2);v.push_back(3);v.push_back(3);v.push_back(4);vector<int>::iterator it=adjacent_find(v.begin(), v.end());if (it == v.end()){cout << "没有找到" << endl;}else{cout << "找到了:" << *it << endl;}return 0;
}

4.binary_search

底层原理就是二分查找,二分查找需要提前排序好才能用,二分查找需要的算力少。

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
int main()
{vector<int> v;for(int i=0;i<10;i++){v.push_back(i);}bool ret = binary_search(v.begin(), v.end(),9);if (ret){cout << "找到了" << endl;}else{cout << "没找到" << endl;}return 0;
}

如果是无序序列,结果未知

5.count

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class person
{
public:person(string name, int age){this->age = age;this->name = name;}bool operator==(const person& p){if (p.age == this->age){return true;}else{return false;}}int age;string name;
};
int main()
{vector<person> v;person p1("刘备", 35);person p2("关羽", 35);person p3("张飞", 35);person p4("赵云", 20);person p5("刘备", 40);v.push_back(p1);v.push_back(p2);v.push_back(p3);v.push_back(p4);v.push_back(p5);person p("诸葛亮", 35);int a = count(v.begin(), v.end(), p);cout << "同年龄的有:" << a << "个" << endl;return 0;
}

关于为什么operator要加const

const Person p1("刘备", 35);

Person p2("关羽", 35);

if (p1 == p2)

{

// 编译错误:无法将 const 对象传递给非 const 引用参数

cout << "年龄相同" << endl;

}

在运算符重载中,参数通常也会被声明为const。这样做的目的是为了扩大函数的适用范围,使其既能接受const对象,也能接受非const对象。

总结:对于统计自定义数据类型的时候,需要配合重载operator==

           对于形参是自定义类型时,要加上const

6.count_if

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
class person
{
public:bool operator()(int val){return val == 2;}
};
int main()
{vector<int> v;v.push_back(1);v.push_back(2);v.push_back(2);v.push_back(2);v.push_back(5);int a = count_if(v.begin(), v.end(), person());cout << "同年龄的有:" << a << "个" << endl;return 0;
}

4.常用排序算法

1.sort

pred是谓词

生序

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void print(int a)
{cout << a << " ";
}
int main()
{vector<int> v;v.push_back(1);v.push_back(2);v.push_back(6);v.push_back(3);v.push_back(5);sort(v.begin(), v.end());for_each(v.begin(), v.end(), print);return 0;
}

降序(利用内建函数对象greater实现降序排序,要包含头文件functional)

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void fun(int a)
{cout << a << " ";
}
int main()
{vector<int> v;v.push_back(1);v.push_back(2);v.push_back(6);v.push_back(3);v.push_back(5);sort(v.begin(), v.end(), greater<int>());for_each(v.begin(), v.end(),fun);return 0;
}

2.random_shuffle

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void fun(int a)
{cout << a << " ";
}
int main()
{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(),fun);return 0;
}

可以加入时间种子来达到真随机效果(srand(unsigned int)time(NULL);)

不过需要包含头文件#include<time.h>

3.merge

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void fun(int a)
{cout << a << " ";
}
int main()
{vector<int> v1;vector<int> v2;vector<int> v3;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+1);}v3.resize(v1.size() + v2.size());merge(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(), v3.end(),fun);return 0;
}

不过要给目标容器提前开辟内存空间用resize

而且合并之后还是一个有序序列

merge合并的两个序列必须是有序序列

4.reverse

5.常用拷贝和替换算法

1.copy

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void fun(int a)
{cout << a << " ";
}
int main()
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);}v2.resize(v1.size());copy(v1.begin(), v1.end(), v2.begin());for_each(v2.begin(), v2.end(),fun);return 0;
}

2.replace

3.replace_if

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}replace_if(v1.begin(), v1.end(), person(), 1000);for_each(v1.begin(), v1.end(),fun);return 0;
}

可以利用仿函数灵活的设置筛选条件

4.swap

swap(v1,v2);

其中两个容器的大小和数值都会交换,不过交换的容器要同种类型

6.常用算术生成算法

1.accumulate

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
#include<numeric>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;for (int i = 0; i <= 100; i++){v1.push_back(i);}int val=accumulate(v1.begin(),v1.end(),0);/*for_each(v1.begin(), v1.end(),fun);*/cout << val << endl;return 0;
}

比较实用,记住要添加头文件#include<numeric>

2.fill

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
#include<numeric>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;for (int i = 0; i < 10; i++){v1.push_back(i);}fill(v1.begin(),v1.end(),99);for_each(v1.begin(), v1.end(),fun);cout << endl;vector<int> v2;v2.resize(10);fill(v2.begin(), v2.end(), 11);for_each(v2.begin(), v2.end(), fun);return 0;
}

如果已经有了数值,会把原来的数值顶替掉

7.常用集合算法

1.set_intersection

交集:即两个容器中数值相同的元素

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
#include<numeric>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+3);}vector<int>v3;v3.resize(min(v1.size(), v2.size()));vector<int>::iterator it=set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(),it,fun);cout << endl;return 0;
}

注意:

set_intersection其中它会返回交际的最后一个元素的迭代器,遍历输出交集的时候不要写end(),要写它返回的迭代器,这样就不会输出无用元素。

存储交集的目标容器需要提前开辟空间,最特殊的情况是大容器包含小容器,即交集就是小容器,所以取小容器的大小即可。

min()包含在algorithm头文件中,找出最小值

2.set_union

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
#include<numeric>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+3);}vector<int>v3;v3.resize(v1.size()+v2.size());vector<int>::iterator it=set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(),it,fun);cout << endl;return 0;
}

最坏的情况是一个相同的都没有,所以开辟大小直接把两个容器的大小加起来就行

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

3.set_different

有两种差集的情况:(谁在前先求谁的差集)

#include<stdio.h>
using namespace std;
#include<string>
#include<vector>
#include<functional>
#include<algorithm>
#include <iostream>
#include<numeric>
void fun(int a)
{cout << a << " ";
}
class person
{
public:bool operator()(int val){return val > 5;}
};
int main()
{vector<int> v1;vector<int> v2;for (int i = 0; i < 10; i++){v1.push_back(i);v2.push_back(i+3);}v2.push_back(99);vector<int>v3;v3.resize(max(v1.size(),v2.size()));vector<int>::iterator it=set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin());for_each(v3.begin(),it,fun);cout << endl;vector<int>::iterator it1 = set_difference(v2.begin(), v2.end(), v1.begin(), v1.end(), v3.begin());for_each(v3.begin(), it1, fun);cout << endl;return 0;
}

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

相关文章:

STL常用算法——C++

1.概述 2.常用遍历算法 1.简介 2.for_each 方式一&#xff1a;传入普通函数&#xff08;printf1&#xff09; #include<stdio.h> using namespace std; #include<string> #include<vector> #include<functional> #include<algorithm> #include…...

UofTCTF-2025-web-复现

感兴趣朋友可以去我博客里看&#xff0c;画风更好看 UofTCTF-2025-web-复现 文章目录 scavenger-huntprismatic-blogscode-dbprepared-1prepared-2timeless scavenger-hunt 国外的一些ctf简单题就喜欢把flag藏在注释里&#xff0c;开源代码找到第一部分的flag 抓个包返回数据…...

Ruby 正则表达式

Ruby 正则表达式 引言 正则表达式&#xff08;Regular Expression&#xff0c;简称Regex&#xff09;是一种强大的文本处理工具&#xff0c;在编程和数据处理中有着广泛的应用。Ruby 作为一种动态、灵活的编程语言&#xff0c;同样内置了强大的正则表达式功能。本文将详细介绍…...

[密码学基础]GB与GM国密标准深度解析:定位、差异与协同发展

[密码学基础]GB与GM国密标准深度解析&#xff1a;定位、差异与协同发展 导语 在国产密码技术自主可控的浪潮下&#xff0c;GB&#xff08;国家标准&#xff09;与GM&#xff08;密码行业标准&#xff09;共同构建了我国商用密码的技术规范体系。二者在制定主体、法律效力、技术…...

代理设计模式:从底层原理到源代码 详解

代理设计模式&#xff08;Proxy Pattern&#xff09;是一种结构型设计模式&#xff0c;它通过创建一个代理对象来控制对目标对象的访问。代理对象充当客户端和目标对象之间的中介&#xff0c;允许在不修改目标对象的情况下添加额外的功能&#xff08;如权限控制、日志记录、延迟…...

15.第二阶段x64游戏实战-分析怪物血量(遍历周围)

免责声明&#xff1a;内容仅供学习参考&#xff0c;请合法利用知识&#xff0c;禁止进行违法犯罪活动&#xff01; 本次游戏没法给 内容参考于&#xff1a;微尘网络安全 上一个内容&#xff1a;14.第二阶段x64游戏实战-分析人物的名字 如果想实现自动打怪&#xff0c;那肯定…...

HarmonyOS 基础语法概述 UI范式

ArkUI框架 - UI范式 ArkTS的基本组成 装饰器&#xff1a; 用于装饰类、结构、方法以及变量&#xff0c;并赋予其特殊的含义。如上述示例中Entry、Component和State都是装饰器&#xff0c;Component表示自定义组件&#xff0c;Entry表示该自定义组件为入口组件&#xff0c;Stat…...

专题讨论2:树与查找

在讨论前先回顾一下定义&#xff1a; BST树的定义 二叉搜索树是一种特殊的二叉树&#xff0c;对于树中的任意一个节点&#xff1a; 若它存在左子树&#xff0c;那么左子树中所有节点的值都小于该节点的值。 若它存在右子树&#xff0c;那么右子树中所有节点的值都大于该节点…...

django之数据的翻页和搜索功能

数据的翻页和搜素功能 目录 1.实现搜素功能 2.实现翻页功能 一、实现搜素功能 我们到bootstrap官网, 点击组件, 然后找到输入框组, 并点击作为额外元素的按钮。 我们需要使用上面红色框里面的组件, 就是搜素组件, 代码部分就是下面红色框框出来的部分。 把这里的代码复制…...

盈达科技GEO供应商:用AICC智能认知攻防系统重构AI时代的“内容主权”

《盈达科技GEO供应商&#xff1a;用AICC智能认知攻防系统重构AI时代的“内容主权”》 ——从全网认知统一到多模态智能投喂&#xff0c;破解生成式AI的内容暗战 前言 当用户向ChatGPT提问“XX品牌空调质量如何”时&#xff0c;AI的回答可能直接决定企业30%的潜在客户流向。 生…...

unity脚本-FBX自动化模型面数校验

根据目前模型资源平均面数预算进行脚本制作&#xff0c;自动化校验模型面数是否符合规范。 *注&#xff1a;文件格式为.cs。需要放置在unity资源文件夹Assets>Editor下。 测试效果&#xff08;拖一个fbx文件进unity时自动检测&#xff09;&#xff1a; 以下为完整代码 us…...

C++用于保留浮点数的两位小数,使用宏定义方法(可兼容低版本Visual Studio)

文章目录 一、 描述二、 样例二、 结果输出 一、 描述 这个宏定义&#xff08;可放入.h头文件里&#xff09;使用基本的数学运算&#xff0c;几乎兼容所有版本的VS&#xff0c;以下可对正数做四舍五入&#xff1a; #define ROUND_TO_TWO(x) ( (floor((x) * 100 0.5) / 100) …...

day30 学习笔记

文章目录 前言一、凸包特征检测1.穷举法2.QuickHull法 二、图像轮廓特征查找1.外接矩形2.最小外接矩形3.最小外接圆 前言 通过今天的学习&#xff0c;我掌握了OpenCV中有关凸包特征检测&#xff0c;图像轮廓特征查找的相关原理和操作 一、凸包特征检测 通俗的讲&#xff0c;凸…...

[密码学基础]密码学发展简史:从古典艺术到量子安全的演进

密码学发展简史&#xff1a;从古典艺术到量子安全的演进 密码学作为信息安全的基石&#xff0c;其发展贯穿人类文明史&#xff0c;从最初的文字游戏到量子时代的数学博弈&#xff0c;每一次变革都深刻影响着政治、军事、科技乃至日常生活。本文将以技术演进为主线&#xff0c;…...

(51单片机)LCD显示温度(DS18B20教程)(LCD1602教程)(延时函数教程)(单总线教程)

演示视频&#xff1a; LCD显示温度 源代码 如上图将9个文放在Keli5 中即可&#xff0c;然后烧录在单片机中就行了 烧录软件用的是STC-ISP&#xff0c;不知道怎么安装的可以去看江科大的视频&#xff1a; 【51单片机入门教程-2020版 程序全程纯手打 从零开始入门】https://www.…...

服务器运维:服务器流量的二八法则是什么意思?

文章目录 用户行为角度时间分布角度应用场景角度 服务器流量的二八法则&#xff0c;又称 80/20 法则&#xff0c;源自意大利经济学家帕累托提出的帕累托法则&#xff0c;该法则指出在很多情况下&#xff0c;80% 的结果是由 20% 的因素所决定的。在服务器流量领域&#xff0c;二…...

高并发秒杀使用RabbitMQ的优化思路

高并发秒杀使用RabbitMQ的优化思路 一、判断是否重复抢购&#xff08;防止一人多次秒杀)的逻辑1. 整体逻辑代码2. 原始判断重复抢购的方式&#xff1a;3. 后来优化为什么用 Redis 判断&#xff1f; 二、高并发下优化过的秒杀逻辑1.秒杀核心逻辑&#xff08;请求入口&#xff09…...

B + 树与 B 树的深度剖析

在数据库领域&#xff0c;B 树和 B 树是两种极为关键的数据结构&#xff0c;它们对于数据的存储、查询以及索引的构建等方面都有着深远的影响。深刻理解这两种树的原理、特性以及它们之间的差异&#xff0c;对于数据库的性能优化、数据组织和管理等工作具有不可替代的重要作用…...

【LeetCode】嚼烂热题100【持续更新】

2、字母异位词分组 方法一&#xff1a;排序哈希表 思路&#xff1a;对每个字符串排序&#xff0c;排序后的字符串作为键插入到哈希表中&#xff0c;值为List<String>形式存储单词原型&#xff0c;键为排序后的字符串。 Map<String, List<String>> m new Ha…...

赛灵思 XC7K325T-2FFG900I FPGA Xilinx Kintex‑7

XC7K325T-2FFG900I 是 Xilinx Kintex‑7 系列中一款工业级 (I) 高性能 FPGA&#xff0c;基于 28 nm HKMG HPL 工艺制程&#xff0c;核心电压标称 1.0 V&#xff0c;I/O 电压可在 0.97 V–1.03 V 之间灵活配置&#xff0c;并可在 –40 C 至 100 C 温度范围内稳定运行。该器件提供…...

【速写】多LoRA并行衍生的一些思考

迁移学习上的一个老问题&#xff0c;怎么做多领域的迁移&#xff1f;以前的逻辑认为领域迁移属于是对参数做方向性的调整&#xff0c;如果两个领域方向相左&#xff0c;实际上不管怎么加权相加都是不合理的。 目前一些做法想着去观察LoRA权重矩阵中的稠密块与稀疏块&#xff0…...

探索智能仓颉!Cangjie Magic:码字之间,意境自生

仓颉输入法&#xff0c;对于许多老牌中文使用者来说&#xff0c;不仅仅是一种输入工具&#xff0c;更是一种情怀&#xff0c;一种文化符号。它以拆字为核心&#xff0c;将汉字结构还原成最原始的构件&#xff0c;再通过特定的编码规则进行输入。然而&#xff0c;随着拼音输入法…...

py默认框架和代码

py默认框架 平常工作日常需要频繁写python脚本&#xff0c;留下一个常用的模板 # template.py import logging import json import time import functools import os from typing import Any, Dict, Optional, Union from pathlib import Path from logging.handlers import …...

通过 Samba 服务实现 Ubuntu 和 Windows 之间互传文件

在 Ubuntu 上进行配置 1. 安装 Samba 服务 打开终端&#xff0c;输入以下命令来安装 Samba&#xff1a; sudo apt update sudo apt install samba2. 创建共享目录 可以使用以下命令创建一个新的共享目录&#xff0c;例如创建名为 shared_folder 的目录&#xff1a; sudo m…...

k8s-1.28.10 安装metrics-server

1.简介 Metrics Server是一个集群范围的资源使用情况的数据聚合器。作为一个应用部署在集群中。Metric server从每个节点上KubeletAPI收集指标&#xff0c;通过Kubernetes聚合器注册在Master APIServer中。为集群提供Node、Pods资源利用率指标。 2.下载yaml文件 wget https:/…...

基于外部中中断机制,实现以下功能: 1.按键1,按下和释放后,点亮LED 2.按键2,按下和释放后,熄灭LED 3.按键3,按下和释放后,使得LED闪烁

题目&#xff1a; 参照外部中断的原理和代码示例,再结合之前已经实现的按键切换LED状态的实验&#xff0c;用外部中断改进其实现。 请自行参考文档《中断》当中&#xff0c;有关按键切换LED状态的内容, 自行连接电路图&#xff0c;基于外部中断机制&#xff0c;实现以下功能&am…...

【我的创作纪念日】 --- 与CSDN走过的第365天

个人主页&#xff1a;夜晚中的人海 不积跬步&#xff0c;无以至千里&#xff1b;不积小流&#xff0c;无以成江海。-《荀子》 文章目录 &#x1f389;一、机缘&#x1f680;二、收获&#x1f3a1;三、 日常⭐四、成就&#x1f3e0;五、憧憬 &#x1f389;一、机缘 光阴似箭&am…...

学习笔记——《Java面向对象程序设计》-继承

参考教材&#xff1a; Java面向对象程序设计&#xff08;第3版&#xff09;微课视频版 清华大学出版社 1、定义子类 class 子类名 extends 父类名{...... }如&#xff1a; class Student extends People{...... } &#xff08;1&#xff09;如果一个类的声明中没有extends关…...

鸿蒙生态新利器:华为ArkUI-X混合开发框架深度解析

鸿蒙生态新利器&#xff1a;华为ArkUI-X混合开发框架深度解析 作者&#xff1a;王老汉 | 鸿蒙生态开发者 | 2025年4月 &#x1f4e2; 前言&#xff1a;开发者们的新机遇 各位鸿蒙开发者朋友们&#xff0c;是否还在为多平台开发重复造轮子而苦恼&#xff1f;今天给大家介绍一位…...

如何收集用户白屏/长时间无响应/接口超时问题

想象一下这样的场景:一位用户在午休时间打开某电商应用,准备购买一件心仪已久的商品。然而,页面加载了数秒后依然是一片空白,或者点击“加入购物车”按钮后没有任何反馈,甚至在结算时接口超时导致订单失败。用户的耐心被迅速消耗殆尽,关闭应用,转而选择了竞争对手的产品…...