c++minmax函数_std :: minmax()函数以及C ++ STL中的示例
c++minmax函数
C ++ STL std :: minmax()函数 (C++ STL std::minmax() function)
minmax() function is a library function of algorithm header, it is used to find the smallest and largest values, it accepts two values and returns a pair of the smallest and largest values, the first element of the pair contains the smallest value and the second element of the pair contains the largest value.
minmax()函数是算法标头的库函数,用于查找最小和最大值,它接受两个值并返回一对最小和最大值,该对中的第一个元素包含最小值,并且该对中的第二个元素包含最大值。
Note:To use minmax() function – include <algorithm> header or you can simple use <bits/stdc++.h> header file.
注意:要使用minmax()函数 –包括<algorithm>头文件,或者您可以简单地使用<bits / stdc ++。h>头文件。
Syntax of std::minmax() function
std :: minmax()函数的语法
std::minmax(const T& a, const T& b);
Parameter(s): const T& a, const T& b – values to be compared.
参数: const T&a,const T&b –要比较的值。
Return value: pair – it returns the pair of the smallest and the largest values.
返回值: pair-返回最小和最大的一对。
Example:
例:
Input:
int a = 10;
int b = 20;
//finding pair of smallest and largest numbet
auto result = minmax(a, b);
cout << result.first << endl;
cout << result.second << endl;
Output:
10
20
C ++ STL程序演示std :: minmax()函数的使用 (C++ STL program to demonstrate use of std::minmax() function)
In this program, we have two integer variables and finding the smallest and the largest values.
在此程序中,我们有两个整数变量并找到最小和最大值。
//C++ STL program to demonstrate use of
//std::minmax() function
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{int a = -10;
int b = -20;
//finding pair of smallest and largest numbet
auto result = minmax(a, b);
//printing the smallest and largest values
cout << "smallest number is: " << result.first << endl;
cout << "largest number is: " << result.second << endl;
return 0;
}
Output
输出量
smallest number is: -20
largest number is: -10
Reference: C++ std::minmax()
参考: C ++ std :: minmax()
翻译自: https://www.includehelp.com/stl/std-minmax-function-with-example.aspx
c++minmax函数
c++minmax函数_std :: minmax()函数以及C ++ STL中的示例相关推荐
- stl中copy()函数_std :: copy_if()函数以及C ++ STL中的示例
stl中copy()函数 C ++ STL std :: copy_if()函数 (C++ STL std::copy_if() function) copy_if() function is a l ...
- stl中copy()函数_std :: rotate_copy()函数以及C ++ STL中的示例
stl中copy()函数 C ++ STL std :: rotate_copy()函数 (C++ STL std::rotate_copy() function) rotate_copy() fun ...
- stl中copy()函数_std :: copy()函数以及C ++ STL中的示例
stl中copy()函数 C ++ STL std :: copy()函数 (C++ STL std::copy() function) copy() function is a library fu ...
- c语言中vector函数大全,vector :: empty()函数,以及C ++ STL中的示例
C ++ vector :: empty()函数 矢量::空()是一个库函数"载体"头,它是用来检查给定的矢量是否是一个空的载体或没有,它返回一个真,如果矢量大小为0,否则返回假. ...
- stl min函数_std :: min()函数以及C ++ STL中的示例
stl min函数 C ++ STL std :: min()函数 (C++ STL std::min() function) min() function is a library function ...
- stl max函数_std :: max_element()函数以及C ++ STL中的示例
stl max函数 C ++ STL std :: max_element()函数 (C++ STL std::max_element() function) max_element() functi ...
- stl min函数_std :: min_element()函数以及C ++ STL中的示例
stl min函数 C ++ STL std :: min_element()函数 (C++ STL std::min_element() function) min_element() functi ...
- stl vector 函数_vector :: at()函数以及C ++ STL中的示例
stl vector 函数 C ++ vector :: at()函数 (C++ vector::at() function) vector::at() is a library function o ...
- stl swap函数_vector :: swap()函数以及C ++ STL中的示例
stl swap函数 C ++ vector :: swap()函数 (C++ vector::swap() function) vector::swap() is a library functio ...
最新文章
- 清华大学:确保博士生每年最低资助标准不低于5.1万元
- pandas 官方API
- 盘点几种MySQL复制的解决方案和常见的错误理解
- python爬虫:使用BeautifulSoup进行查找
- mingw w64 matlab,Matlab安装MinGW-w64问题解决
- 22个国外电子商务系统
- 猿大师播放器网页播放海康威视RTSP流闪退,用新版VLC播放器播放也闪退,但是用某个老版本VLC播放器却没问题,该怎么办?
- 阿里云域名怎么注册和使用(新手教程)
- 实现搜索框(含历史搜索记录)
- 关于CRC校验的一些总结
- CentOS7.0如何查看MAC地址
- MPU9250的基本框架
- 给通达信独立下单软件(tc.exe)加上快捷键 TCOEM.XML
- SpringBoot整合Redis配置MyBatis二级缓存
- 软件功能测试包含了哪些测试项目?功能测试报告收费标准
- 拜占庭将军问题(二)——口头协议
- 重磅 | Stratifyd发布《2021金融服务行业客户体验报告》
- 区块链能否让信息永生? 或为人类留下永久有用的遗产
- 压缩包太大导致的部署问题
- java 多线程(三)
热门文章
- UVM—virtual sequencer and virtual sequence详解
- phx.gen.html 生成器
- 紫光展锐发布系统级安全的高性能5G SoC移动平台T820
- java中的build类_30 Java设计模式系列-建造者(Build)模式
- Stimulsoft 仪表板.JS 2022.2.1
- 关于使用win10易升,升级后电脑变卡解决方法
- 索尼rx1r人脸识别_一波三折的闲鱼翻车记——索尼RX1R入手记录
- 季羡林基金会与孔明在线联手弘扬国学文化
- 巴卡斯杯 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- 西安恒智小寨java_长安反编译工具 java