Perché seguente programma non restituisce valore minimo come 1.std :: vector e std :: comportamento min
#include <vector>
#include <algorithm>
#include <iostream>
int main (int argc, char **argv) {
std::vector<int> test;
test.push_back(INT_MAX);
test.push_back(1);
int min = *(std::min(test.begin(), test.end()));
std::cout << "Minimum = " << min << std::endl;
}
Restituisce minimum
valori 2147483647
Ah, questo è quasi certamente quello che vuole. – GManNickG
Il valore restituito da 'std :: min_element()' è un iteratore quindi deve essere dereferenziato. – hmjd
@hmjd Sì hai ragione. – FailedDev