复制 #include<iostream>#include<vector>#include<algorithm>using namespace std;intmain(int argc,char**argv){float arr[]={1.0,2.0,3.5,6.7,1.22,0.77,90.0,36.11};int arr_length=sizeof(arr)/sizeof(arr[0]);// 数组长度// max_element(arr, arr+arr_length) 计算出来是一个地址,我们需要取该地...
std::vector<double> v {1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0}; std::vector<double>::iterator biggest = std::max_element(std::begin(v), std::end(v)); //or std::vector<double>::iterator biggest = std::max_element(v.begin(), v.end); std::cout << "Max ele...
vector<double> v = {1.0, 3.55, 2.33, 4.55, 2.11, 7.66, 9.00, 7.1, 88.66, 76.99}; auto biggest = max_element(v.begin(), v.end()); auto smallest = min_element(v.begin(), v.end()); cout << "max val is: " << *biggest << "t the max val index is "<< distance(v.begi...