c ++ stl_获取列表的第一个和最后一个元素| C ++ STL

本文介绍了在C++ STL中如何使用front()和back()函数来访问列表的第一个和最后一个元素。这两个函数分别返回列表的首尾元素。
摘要由CSDN通过智能技术生成

c ++ stl

Given a list with some of the elements, we have to access its first and last elements of the list in C++ (STL) program.

给定包含某些元素的列表,我们必须在C ++(STL)程序中访问列表的第一个和最后一个元素。

列表的front()和back()函数 (front() and back() function of the list)

These are two functions which can be used to get the first and last element of the list. 'front()' returns the first element and 'back()' returns the last element.

这是两个函数,可用于获取列表的第一个和最后一个元素。 'front()'返回第一个元素, 'back()'返回最后一个元素。

Let's implement the program below...

让我们实现下面的程序...

Example:

例:

    Input:
    
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值