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

app 微商城网站建设电商网站开发计划书

app 微商城网站建设,电商网站开发计划书,怎么做一个好的wordpress,全球营销策划公司排名本文主要涉及以下几个函数&#xff1a; reverse&#xff1a;反转序列。unique&#xff1a;移除相邻重复元素。sort&#xff1a;对序列进行排序。lower_bound 和 upper_bound&#xff1a;查找目标值的边界位置。头文件均为<algorithm> 1. reverse 功能&#xff1a;反转指…

本文主要涉及以下几个函数:

  • reverse:反转序列。
  • unique:移除相邻重复元素。
  • sort:对序列进行排序。
  • lower_boundupper_bound:查找目标值的边界位置。
  • 头文件均为<algorithm>

1. reverse

功能:反转指定范围内的元素顺序。reverse 不会改变容器的大小,仅改变元素的顺序。

void reverse(BidirectionalIterator first, BidirectionalIterator last);
#include <iostream>
#include <vector>
#include <algorithm>int main() {std::vector<int> v = {1, 2, 3, 4, 5};std::reverse(v.begin(), v.end());for (auto i : v) {std::cout << i << " ";}// 输出:5 4 3 2 1
}

2. unique

功能:移除相邻重复元素(不保证全局唯一性),返回调整后序列的末尾迭代器。

注意unique 只能移除相邻的重复元素,因此通常需要先对容器进行排序。

ForwardIterator unique(ForwardIterator first, ForwardIterator last);
#include <iostream>
#include <vector>
#include <algorithm>int main() {std::vector<int> v = {1, 2, 2, 3, 3, 4, 5};std::vector<int>::iterator it = std::unique(v.begin(), v.end());v.erase(it, v.end()); for (auto i : v) {std::cout << i << " ";}// 输出:1 2 3 4 5
}

3. sort

功能:对指定范围内的元素进行排序,默认升序。

void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp = std::less<T>());
#include <iostream>
#include <vector>
#include <algorithm>int main() {std::vector<int> v = {5, 3, 8, 6, 2};std::sort(v.begin(), v.end());for (auto i : v) {std::cout << i << " ";}// 输出:2 3 5 6 8
}

自定义排序规则

std::sort(v.begin(), v.end(), [](int a, int b) { return a > b; });
// 降序

4. lower_bound 和 upper_bound 函数

功能:分别查找第一个大于或等于目标值的元素位置,以及第一个大于目标值的元素位置。

注意lower_boundupper_bound 都要求输入序列是有序的。

ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
#include <iostream>
#include <vector>
#include <algorithm>int main() {std::vector<int> v = {1, 2, 2, 3, 4, 4, 5};auto lb = std::lower_bound(v.begin(), v.end(), 3); // 第一个 >=3 的位置auto ub = std::upper_bound(v.begin(), v.end(), 3); // 第一个 >3 的位置std::cout << "Lower bound: " << *lb << std::endl; // 输出:3std::cout << "Upper bound: " << *ub << std::endl; // 输出:4
}

在这里插入图片描述


文章转载自:

http://XIPEUtpf.nhzxr.cn
http://UsJsARRs.nhzxr.cn
http://WthdjA4l.nhzxr.cn
http://RBe56o3G.nhzxr.cn
http://AvUmCsiT.nhzxr.cn
http://8uNTzHFs.nhzxr.cn
http://pgWhm8Oj.nhzxr.cn
http://Gvw871E2.nhzxr.cn
http://p0fTh1C9.nhzxr.cn
http://Mq5wX43x.nhzxr.cn
http://aftHM6YO.nhzxr.cn
http://2pYYj7Ou.nhzxr.cn
http://K1Od8n5P.nhzxr.cn
http://l4IgPFYc.nhzxr.cn
http://9jIJKZ9O.nhzxr.cn
http://5xbF3QmF.nhzxr.cn
http://bWl3bm2M.nhzxr.cn
http://qxiR3Kxs.nhzxr.cn
http://8IahBY5T.nhzxr.cn
http://PkSp22ER.nhzxr.cn
http://HfJ0F9kS.nhzxr.cn
http://7tImrFYG.nhzxr.cn
http://PQ27VO2P.nhzxr.cn
http://odaMVXMB.nhzxr.cn
http://25Xs3RHs.nhzxr.cn
http://0Le9GKF1.nhzxr.cn
http://KeukCk3W.nhzxr.cn
http://bJF080Nr.nhzxr.cn
http://qFgxBAkQ.nhzxr.cn
http://Hf0T0XiU.nhzxr.cn
http://www.dtcms.com/wzjs/750468.html

相关文章:

  • 佛山茂名网站建设wordpress 获取图片路径
  • 建设历史文化旅游宣传网站wordpress网页移动端
  • 给人做ppt的网站安徽网站建设公司
  • 曲阳县做网站做视频网站违法
  • 建设银行网站银行登录国外优秀的网站
  • 网站中留言板怎么做装修平台app有哪些
  • 台州做鞋子网站道可道在线设计平台
  • 中国网站建设市场分析报告wordpress 注册
  • 长沙市旅游景点欧美seo查询
  • 做冻品海鲜比较大的网站有哪些域名打不开网站
  • 哪家外贸网站做的好wordpress最新版本下载
  • 网站建设免费建站文字头像在线制作
  • 青海省建设厅查询网站网站ip被屏蔽怎么办
  • 网站怎么搬家到快云vps里面去啊wordpress播放视频
  • 一般网站的跳出率做网站怎么建站点
  • 东莞网站设计找哪里医疗器械三证是哪三证
  • 多媒体网站开发实战贵阳网上注册公司流程
  • 山西品牌网站建设如何找外贸网站建设公司
  • 辖网站建设 网站设计手机网站模板代码
  • 婚庆公司网站设计互联网定制产品网站
  • 新手学做网站需要注意的几点用phpmysql做网站
  • 网站版面的图文是怎么做的网上医疗和医院网站建设制作
  • 模板网站和定制网站有什么区别天津网站建设公
  • 为什么要做个人网站网店美工需要学什么软件
  • 长宁企业网站建设手机会员卡管理系统
  • 拼多多cms网站怎么做海口注册公司流程及费用
  • 毕设做网站网站制作网站建设案例
  • 吉安做网站的公司广告设计专业烧钱吗
  • 著名网站设计师百度6大核心部门
  • 网站建设合同附件明细网站如何做中英文双语言版本