stl vector 函数_vector :: crend()函数以及C ++ STL中的示例

stl vector 函数

C ++ vector :: crend()函数 (C++ vector::crend() function)

vector::crend() is a library function of "vector" header, it is used to get the first element of a vector from reverse ending, it returns a const reverse iterator pointing to the element preceding the first element (i.e. reverse ending) of a vector.

vector :: crend()“ vector”头文件的库函数,用于从反向结尾获取向量的第一个元素,它返回一个const反向迭代器,指向第一个元素之前的元素(即反向结尾)向量。

It returns a const_reverse_iterator which is an iterator point to the constant content(vector), the const_reverse_itertator can be increased or decreased just like an iterator but it cannot be used to update/modify the vector content it points to.

它返回const_reverse_iterator ,它是指向常量content(vector)的迭代器,可以像迭代器一样增加或减少const_reverse_itertator ,但不能用于更新/修改其指向的向量内容。

Note: To use vector, include <vector> header.

注意:要使用向量,请包含<vector>标头。

Syntax of vector::crend() function

vector :: crend()函数的语法

    vector::crend();

Parameter(s): none – It accepts nothing.

参数: 无 –不接受任何内容。

Return value: const_reverse_iterator – It returns a const reverse iterator pointing to the element preceding the first elements of the vector.

返回值: const_reverse_iterator –它返回一个const反向迭代器,指向向量的第一个元素之前的元素。

Example:

例:

    Input:
vector<int> vector1{ 1, 2, 3, 4, 5 };
Function call:
vector<int>::const_iterator crit;
crit = vector1.crend()-1;
cout<

C++ program to demonstrate example of vector::crend() function

Output

first element is: 10

Reference: C++ vector::crend()



TOP Interview Coding Problems/Challenges

  • Run-length encoding (find/print frequency of letters in a string)

  • Sort an array of 0's, 1's and 2's in linear time complexity

  • Checking Anagrams (check whether two string is anagrams or not)

  • Relative sorting algorithm

  • Finding subarray with given sum

  • Find the level in a binary tree with given sum K

  • Check whether a Binary Tree is BST (Binary Search Tree) or not

  • 1[0]1 Pattern Count

  • Capitalize first and last letter of each word in a line

  • Print vertical sum of a binary tree

  • Print Boundary Sum of a Binary Tree

  • Reverse a single linked list

  • Greedy Strategy to solve major algorithm problems

  • Job sequencing problem

  • Root to leaf Path Sum

  • Exit Point in a Matrix

  • Find length of loop in a linked list

  • Toppers of Class

  • Print All Nodes that don't have Sibling

  • Transform to Sum Tree

  • Shortest Source to Destination Path



Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.


翻译自: https://www.includehelp.com/stl/vector-crend-function-with-example.aspx

stl vector 函数

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

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

相关文章

.Net DateTime.ToString 格式化输出 (转载)

原文 虽然 System.DateTime 本身已经具有了不少现成的格式化输出&#xff0c;例如&#xff1a; ToLongDateString, ToShortTimeString, ToUniversalTime 等&#xff0c;但是却远远不能满足我们实际的需要&#xff0c;这就要用到了 DateTime.ToString&#xff0c;就要提到 DateT…

modelsim 编译 xilinx库

1.为单个工程加入库 在某一个目录建立工程 然后 vlib unisim vcom -work unsim *.vhd 然后就加入了unisim库 如果是windows的话&#xff0c;工程文件mpf应该是记录了这个库的信息&#xff0c;所以重新打开这个工程时&#xff0c;依然有这个库 linux&#xff0c;不用gui界面…

php 字符串匹配 like,ThinkPHP like模糊查询,like多匹配查询,between查询,in查询,一般查询书写方法...

搜索热词ThinkPHP的数据库条件查询语句有字符串式&#xff0c;数组式书写方法字符串式即是原生式&#xff0c;数组式查询语句因书写方式与特定字符的原因比较复杂&#xff0c;下面为大家例出了常用的ThinkPHP数组式查询语句的使用方法ThinkPHP一般查询$data_gt[id]array(gt,8);…

C++---汉明距离

两个整数之间的汉明距离指的是这两个数对应二进制位不同的位置的数目。 【输入形式】 给出两个整数x和y(0<x,y<2^31)&#xff0c;用空格分隔 【输出形式】 输出他们之间的汉明距离 【样例输出】 1 4 【样例说明】 00000000 00000000 00000000 00000001 00000000 00000000…

Opencv基础画图函数——line、circle、rectangle、Rect、ellipse、polylines、putText函数的用法

目录1、line函数2、circle函数3、rectangle、Rect函数4、ellipse函数5、polylines函数6、随机初始化颜色7、putText函数总结1、line函数 line(img,(0,0),(511,511),(255,0,0),5)这个函数有5个参数&#xff0c;img是图像名称&#xff0c;起点坐标&#xff0c;终点坐标&#xff…

GCC 里面的一些命令

记录一下常用GCC 相关的命令和参数 ldd ---> print share library dependenciy LD_LIBRARY_PATH---> environment variable, it will search the path accord to this variable. Also check the ldd to verify this environmental variable ldconfig-----> configure…

理解关联容器“map”的关键点

map有一个构造函数: map<k, v> m(b, e); 《C Primer》解释为&#xff1a;“创建 map 类型的对象 m&#xff0c; 存储迭代器 b 和 e 标记的范围内所有元素的副本&#xff0c;元素的类型必须能转换为 pair<const k, v>”&#xff0c;这个构造函数理解起来没有另外两个…

c语言中图形驱动程序功能_C / C ++中的图形:一些更有趣的功能

c语言中图形驱动程序功能In this Advance Learning Tutorial of C / C today, we are going to tell you about some of the functions that can be used to make the program more attractive. This works on both text and graphics modes. That is why knowing these funct…

php 载入css就可以显示,如何在进度条加载后显示页面

1.思路&#xff1a;加入很多图片&#xff0c;以延迟加载时间&#xff0c;实现加载完后显示图片。定义一个外层p&#xff0c;覆盖住图片&#xff0c;在内层p中引入加载时显示的图片&#xff0c;让内层p居中在页面上&#xff0c;利用setInterval定时器设置3秒后将外层p隐藏&#…

如何获取轮廓(连通域)的面积、周长、矩形度、圆形度、宽长比、周径比等形状描述符?

博主联系方式&#xff1a; QQ:1540984562 QQ交流群&#xff1a;892023501 群里会有往届的smarters和电赛选手&#xff0c;群里也会不时分享一些有用的资料&#xff0c;有问题可以在群里多问问。 目录前言1、轮廓面积获取函数2、轮廓周长获取函数3、轮廓圆形度计算4、矩形度计算…

01-基础部分

一、tensorflow和opencv测试 import tensorflow as tf import cv2hello tf.constant(hello tensorflow) session tf.Session() print(session.run(hello))print(hello opencv)运行效果如下&#xff1a; 二、基础部分 1、opencv基础 代码三部曲&#xff1a; 1、引入Open…

网络和通信 - Silverlight 中的 HTTP 通信和安全

Silverlight 支持几种使用 HTTP/HTTPS 的方案。虽然可以使用多种方式和技术执行 HTTP 调用&#xff0c;但是下表描述的是针对这些 HTTP 通信方案的建议方法 执行 HTTP 调用的选项 确定应由浏览器还是客户端来执行应用程序的 HTTP 处理后&#xff0c;应在创建任何 Web 请求之前指…

linux下g++和gcc_Linux中gcc和g ++有什么区别?

linux下g和gccgcc和g 之间的区别 (Difference between gcc and g) Both are the compilers in Linux to compile and run C and C programs. Initially gcc was the GNU C Compiler but now a days GCC (GNU Compiler Collections) provides many compilers, two are: gcc and …

WT2605C高品质音频蓝牙语音芯片:外接功放实现双声道DAC输出的优势

在音频处理领域&#xff0c;双声道DAC输出能够提供更为清晰、逼真的音效&#xff0c;增强用户的听觉体验。针对这一需求&#xff0c;唯创知音的WT2605C高品质音频蓝牙语音芯片&#xff0c;通过外接功放实现双声道DAC输出&#xff0c;展现出独特的应用优势。 一、高品质音频处理…

对c++primer 16.6.1的第4小节的代码说明

这段代码是这样的: template<typename T>int compare(const T& t1,const T& t2){ cout<<"范型"<<endl; return 1;} int main(){   cout<<compare("hello","world")<<endl;} template<> int compa…

php curl form-data,在php curl multipart / form-data请求中发送一个文件和json数据

我正在尝试在PHP的curl请求中上传文件和json数据 . 请求在命令行中使用curl正常工作 . 这是命令行中的curl请求&#xff1a;curl -v --basic -uusername -F file"documentTest.pdf;typeapplication/octet-stream" -F data{"nomDocument":"test.pdf&qu…

角点检测(Harris角点检测法)

博主联系方式&#xff1a; QQ:1540984562 QQ交流群&#xff1a;892023501 群里会有往届的smarters和电赛选手&#xff0c;群里也会不时分享一些有用的资料&#xff0c;有问题可以在群里多问问。 目录原理讲解【1】为何选取角点作为特征&#xff1f;【2】角点的定义&#xff1a;…

02-图像的几何变换

一、图片缩放 imageInfo&#xff1a;图片宽、高、通道个数等 缩放&#xff1a; 等比例缩放&#xff1a;宽高比不变 任意比例缩放&#xff1a;图片拉伸、非拉伸 窗体大小 实现步骤&#xff1a; 1&#xff0c;完成图像的加载&#xff0c;拿到图像的数据信息 2&#xff0c;图片的宽…

c ++查找字符串_C ++数组| 查找输出程序| 套装5

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>using namespace std;int main(){char* STR[] { "HELLO", "HIII", "RAM", "SHYAM", "MOHAN" };cout << (*STR 2)[2];return 0;}Output: 输出&…

MSSQL 链接Oracle 表

在Oracle中&#xff0c;要访问远程的另外一台数据库的话&#xff0c;是建立DBlink的方式。 在MSSQL中&#xff0c;则是以建立“link server 链接服务器”来远程访问另外一台数据库。 现在从MSSQL 2005访问Oracle的scott.dept。 首先&#xff0c;安装Oracle的客户端PLSQL DEVELO…