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

stl vector 函数

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

vector::crbegin() is a library function of "vector" header, it is used to get the last element of a vector using const_reverse_iterator, it returns a const reverse iterator pointing to the last elements (i.e. the reverse beginning) of a vector.

vector :: crbegin()“ vector”头文件的库函数,用于使用const_reverse_iterator获取向量的最后一个元素,它返回一个const反向迭代器,指向向量的最后一个元素(即,反向开始) 。

It returns a const_reverse_iterator which is an iterator point to the constant content(vector), the const_reverse_iterator 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_iterator ,但不能用于更新/修改其指向的向量内容。

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

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

Syntax of vector::crbegin() function

vector :: crbegin()函数的语法

    vector::crbegin();

Parameter(s): none – It accepts nothing.

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

Return value: const_reverse_iterator – It returns a const reverse iterator pointing to the last element 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.crbegin();
cout<

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

Output

last element is: 50

Reference: C++ vector::crbegin()



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-crbegin-function-with-example.aspx

stl vector 函数

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

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

相关文章

ReactNative学习笔记(二)Flex布局

flexDirection 决定主轴方向 column&#xff1a;垂直方向为主轴row:水平方向为主轴justifyContent 决定主轴元素排列方式 flex-startflex-endcenterspace-betweenspace-aroundalignItems 决定侧轴元素排列方向 flex-startflex-endcenterbaselinestretch

cad导出 dxf后中文不显示_CAD快速看图 for Mac

CAD快速看图 for Mac是一款非常小巧、快速、方便的DWG看图工具&#xff0c;CAD快速看图 Mac版可脱离AutoCAD最快速、最方便浏览DWG和DXF图纸&#xff0c;支持二维或三维图纸&#xff0c;支持高清、多文件和云字体&#xff0c;非常实用的一款CAD看图软件&#xff0c;CAD快速看图…

scala运算符_Scala的所有符号运算符是什么意思?

scala运算符Scala的符号运算符 (Scalas symbolic operators) The symbolic operators in Scala are symbols that have a specific task that they perform when called in a Scala program. Scala library defines a lot of symbols that can be used while programming in Sc…

关于java.util.ConcurrentModificationException和remove倒数第二个元素

2019独角兽企业重金招聘Python工程师标准>>> 首先是两段代码的执行结果&#xff1a; 代码一&#xff1a; public class TestListRemove {public static void main(String[] args) {List<Integer> list new ArrayList<Integer>();list.add(1);list.add(…

linux 操作mysql 数据库命令_Linux 操作数据库命令

一、连接数据库格式&#xff1a; mysql -h主机地址 -u用户名 &#xff0d;p用户密码mysql -hlocalhost -uroot -p123注&#xff1a;-h,-u,-p 后面不加空格&#xff0c;进入数据库操作后每个命令结尾都需加“&#xff1b;(分号)”二、退出MYSQL命令exit (回车)三、显示所有数据库…

fragment和Activity同时操作UI引起的延迟、卡顿

最近项目中遇到一个问题&#xff0c;app首页的Activity中由若干个Fragment页面组成&#xff0c;其中一个fragment页面是由一个GridView和ListView组成的列表&#xff0c;如果列表中数据量过大的时候&#xff0c;在请求数据的时候点击页面上的其他按钮会无响应&#xff0c;直到该…

怎么删除mysql的压缩包_压缩包版mysql怎么卸载

MySQL是一个小巧玲珑但功能强大的数据库&#xff0c;目前十分流行。但是官网给出的安装包有两种格式&#xff0c;一个是msi格式&#xff0c;一个是zip格式的。那么压缩版mysql要怎么卸载&#xff1f;下面本篇文章就来大家介绍一下&#xff0c;希望对你们有所帮助。卸载压缩包版…

obj.val 非数组_在Ruby中使用Array.new(size,obj)创建数组

obj.val 非数组In the previous article, we have learnt how we can declare an Array class instance with the help of Array.[](*args) method? You can also notice that in the program codes written to demonstrate all those methods are having Array instances dec…

julia在mac环境变量_在Julia中找到值/变量的类型

julia在mac环境变量To find the type of a variable/value, we use the typeof() function – it accepts a parameter whose type to be found and returns its data type. 为了找到变量/值的类型&#xff0c;我们使用typeof()函数-它接受要查找其类型的参数并返回其数据类型。…

lambda表达式之进化

前言在C#我们可以自定义委托&#xff0c;但是C#为什么还要内置泛型委托呢&#xff1f;因为我们常常要使用委托&#xff0c;如果系统内置了一些你可能会用到的委托&#xff0c;那么就省去了定义委托&#xff0c;然后实例化委托的步骤&#xff0c;这样一来既使代码看起来简洁而干…

mysql返回行数_如何计算MySQL查询返回的行数?

How can I count the number of rows that a MySQL query returned?解决方案Getting total rows in a query result...You could just iterate the result and count them. You dont say what language or client library you are using, but the API does provide a mysql_nu…

md5不是对称密码算法_密码学中的消息摘要算法5(MD5)

md5不是对称密码算法In cryptography, MD5 (Message-Digest algorithm 5) is a mainly used cryptographic hash function with a 128-bit hash value. As we use in an Internet standard (RFC 1321), MD5 has been employed or developed in a more variety of security appl…

Windows 7 SID 修改

在安裝Windows系統時會產生一個獨一無二的SID (Security ID)&#xff0c;它用來識別每一部主機&#xff0c;若在同一個區域網路內有兩部相同SID的主機&#xff0c;會出現警告訊息。一般而言&#xff0c;每次安裝時的SID不可能會發生重複&#xff0c;但若是使用TrueImage或Ghost…

discuz mysql 类_discuz7 phpMysql操作类

MySql数据库连接类&#xff0c;大家可以看下网上老手们用的什么方法&#xff0c;大家可以直接拿来用&#xff0c;但前提是大家能熟练的掌握的基础上&#xff0c;这样才能有所进步。/** MySql数据库连接类* mysql.class.php 2009.04.15 by Hackbaby*/class dbstuff {var $versio…

1 并发模型

并发系统可以采用多种并发编程模型来实现。并发模型指定了系统中的线程如何通过协作来完成分配给它们的作业。不同的并发模型采用不同的方式拆分作业&#xff0c;同时线程间的协作和交互方式也不相同。这篇并发模型教程将会较深入地介绍目前&#xff08;2015年&#xff0c;本文…

Java String compareTo()方法与示例

字符串compareTo()方法 (String compareTo() Method) compareTo() is a String method in Java and it is used to compare two strings (case-sensitive). compareTo()是Java中的String方法&#xff0c;用于比较两个字符串(区分大小写)。 If both strings are equal – it r…

nginx mysql 查询系统_nginx/mysql查看内存占用

查看每个php-fpm平均占用系统内存,也适用看nginx/mysqld等,把php-fpm换成mysqldps --no-headers -o "rss,cmd" -C php-fpm | awk { sum$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }查看占用内存[rootcentos69 ~]# ps -ylC php-fpm --sort:r…

linux用户及权限详解(20170425)

计算机资源权限用户用户&#xff0c;容器&#xff0c;关联权限&#xff1a;用户组&#xff0c;方便的指派权限用户&#xff1a;标示符用户组&#xff1a;标示符r 、w、x&#xff1a;1、2、4对于文件r:可读&#xff0c;可以使用类似cat等命令查看文件内容w&#xff1a;可写&…

kotlin 判断数字_Kotlin程序检查数字是否为质数

kotlin 判断数字A prime number is a natural number that is greater than 1 and cannot be formed by multiplying two smaller natural numbers. 质数是大于1的自然数&#xff0c;不能通过将两个较小的自然数相乘而形成。 Given a number num, we have to check whether nu…

mysql gtid配置_mysql 5.7 GTID主从配置

binlog-format&#xff1a;二进制日志的格式&#xff0c;有row、statement和mixed几种类型&#xff1b;需要注意的是&#xff1a;当设置隔离级别为READ-COMMITED必须设置二进制日志格式为ROW&#xff0c;现在MySQL官方认为STATEMENT这个已经不再适合继续使用&#xff1b;但mixe…