当前位置:网站首页>Question brushing tool h
Question brushing tool h
2022-08-10 08:29:00 【Small guest】
C++Commonly used standard library functions
algorithm
#include<algorithm>
//第一个函数,Get the maximum and minimum values of the container,
max_element()
min_element()
//返回的是一个指针,if return value,需要*max_element 进行解引用
count(iter1,iter2,value)The function returns an integer number for counting
distance(iter1,iter2)
// 排序算法
sort(iter1,iter2,bool),0Represents a sequential order,1反之
reverse(iter1,iter2)
for_each(cbegin(v),cend(v),[](const auto&x){cout<<x<<",";})
#include<bits/stdc++.h>//万能头文件
using namespace std;
int main(){
vector<int> vec(5,6);
vector<int> vec1{
4,6,7,8,8};
//The corresponding address is returned
auto i = max_element(vec1.begin(),vec1.end());
//Output the first position of the maximum value
cout<<"最大值是:"<< distance(vec1.begin(),i);
auto j = *min_element(vec1.begin(),vec1.end());
int n = count(vec.begin(),vec.end(),6);
string s = "aaabcdaaa!!!";
int cnt= count(s.begin(),s.end(),'b');
//The address corresponding to the maximum value is :
//cout<<i<<endl;
//The number corresponding to the minimum value is
cout<<j<<endl;
//The corresponding number of outputs is
cout<<n<<endl;
//输出数组,For coercion
for_each(cbegin(vec1),cend(vec1),[](const auto&x){
cout<<x<<",";});
for_each(vec1.begin(),vec1.end(),[](const auto&x){
cout<<x<<",";});
cout<<"wpf!!!"<<endl;
return 0;
}
class Solution {
public:
int massage(vector<int>& nums) {
vector<vector<int>> vec(nums.size(),vector<int>(2));
if(nums.size() == 0) return 0;
vec[0][0] = 0;
vec[0][1] = nums[0];
int max0 = nums[0];
for(int i = 1;i<nums.size();i++){
vec[i][0] = max(vec[i-1][0],vec[i-1][1]);
vec[i][1] = vec[i-1][0]+nums[i];
vector<int> T{
vec[i][0],vec[i][1],max0};
max0 = *max_element(cbegin(T),cend(T));
}
return max0;
}
};
边栏推荐
猜你喜欢

第十六天&charles的基本操作

Add spark related dependencies and packaging plugins (sixth bullet)

The probability distribution and its application

同步锁synchronized追本溯源

Unity—UGUI control

CV+Deep Learning——网络架构Pytorch复现系列——classification(三:MobileNet,ShuffleNet)

推荐几个高质量的软件测试实战项目

PHP笔记 28 29 30 31

day16--抓包工具Charles的使用

Relaxation class: the boss will martial arts, who also can not hold up against!The charm of six sigma training
随机推荐
NaiveUI中看起来没啥用的组件(文字渐变)实现原来这么简单
Ask next CDC mysql to Doris. Don't show the specific number of lines, how to do?
Introduction to the delta method
机器人控制器编程实践指导书旧版-实践二 传感器(模拟量)
不想再干会计了,蝶变向新,勇往直前,最后成功通过转行测试实现月薪翻倍~
m.bjhjwy.com全面教学设备 类型包括: 教学仪器, 教学设备 ,
【一起学Rust | 进阶篇 | RMQTT库】RMQTT消息服务器——安装与集群配置
解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
本地生活商家如何通过短视频赛道,提升销量曝光量?
Rust学习:6.1_复合类型之切片
How AliExpress sellers seize product search weight
Obtain - 65 [chances] : "soldiers, subtlety also - 7-36 meter reading - defeat
IDLE development wordCount program (5)
Docker搭建Mysql一主一从
硬件工程师90天学习资料及笔记汇总20220730
快速输入当前日期与时间
ShardingSphere入门
placeholder 1
JS reduce
qrcode-----生成二维码