c++ - 在 *min_element (first_index, last_index); 函数,为什么 last_index 被排除在最小计算中?
问题描述
我预计下面的程序会给出 0 作为输出,但实际上它是 1。为什么考虑第一个元素而最后一个元素不考虑最小计算?
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> arr = {5,4,3,2,1,0};
cout<<*min_element(arr.begin()+1,arr.begin()+5);
return 0;
}
解决方案
推荐阅读
- mysql - 如何从前两列中获取月份和年份的完整日期,并使用完整日期更新第三列
- redux - 何时将 Selector(Reselect) 与 react redux 一起使用
- spring - Spring Boot 身份验证有时仅适用于 Google Cloud
- popover - 在 Popover 中选择 SwiftUI 单元格
- c# - 在不更改 url 的情况下显示自定义页面
- npm - 安装PhoneGap插件的傻瓜指南
- python-xarray - 具有二级索引的一维 xarray
- android - 服务未重新启动
- python-3.x - 错误:“NoneType”对象没有属性“_inbound_nodes”
- swift - 如何在 SwiftUI 中访问父框架