日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

stl min函数_std :: min()函数以及C ++ STL中的示例

發(fā)布時(shí)間:2025/3/11 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 stl min函数_std :: min()函数以及C ++ STL中的示例 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

stl min函數(shù)

C ++ STL std :: min()函數(shù) (C++ STL std::min() function)

min() function is a library function of algorithm header, it is used to find the smallest value from given two values, it accepts two values and returns the smallest value and if both the values are the same it returns the first value.

min()函數(shù)是算法標(biāo)頭的庫(kù)函數(shù),用于從給定的兩個(gè)值中查找最小值,它接受兩個(gè)值并返回最小值,如果兩個(gè)值相同,則返回第一個(gè)值。

Note:To use min() function – include <algorithm> header or you can simple use <bits/stdc++.h> header file.

注意:要使用min()函數(shù) –包括<algorithm>頭文件,或者您可以簡(jiǎn)單地使用<bits / stdc ++。h>頭文件。

Syntax of std::min() function

std :: min()函數(shù)的語(yǔ)法

std::min(const T& a, const T& b);

Parameter(s): const T& a, const T& b – values to be compared.

參數(shù): const T&a,const T&b –要比較的值。

Return value: T – it returns the smallest value of type T.

返回值: T –返回類型T的最小值。

Example:

例:

Input:int a = 10;int b = 20;//finding smallest valuecout << min(a,b) << endl;Output:10

C ++ STL程序演示了std :: min()函數(shù)的使用 (C++ STL program to demonstrate use of std::min() function)

In this example, we are going to find the smallest values from given values of different types.

在此示例中,我們將從不同類型的給定值中找到最小值。

#include <iostream> #include <algorithm> using namespace std;int main() {cout << "min(10,20) : " << min(10, 20) << endl;cout << "min(10.23f,20.12f): " << min(10.23f, 20.12f) << endl;cout << "min(-10,-20) : " << min(-10, -20) << endl;cout << "min('A','a') : " << min('A', 'a') << endl;cout << "min('A','Z') : " << min('A', 'Z') << endl;cout << "min(10,10) : " << min(10, 10) << endl;return 0; }

Output

輸出量

min(10,20) : 10 min(10.23f,20.12f): 10.23 min(-10,-20) : -20 min('A','a') : A min('A','Z') : A min(10,10) : 10

Reference: C++ std::min()

參考: C ++ std :: min()

翻譯自: https://www.includehelp.com/stl/std-min-function-with-example.aspx

stl min函數(shù)

總結(jié)

以上是生活随笔為你收集整理的stl min函数_std :: min()函数以及C ++ STL中的示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。