C++ minmax_element求极值

求vector数组nums的最小值和最大值

//仅需要知道数组的开头和结尾
auto res = minmax_element(nums.begin(), nums.end());
  cout << "最小值:" << *(res.first);
  cout << "最大值:" << *(res.second);

猜你喜欢

转载自blog.csdn.net/qq_43641765/article/details/111725316
今日推荐