Qt求极值
1. 求最大值
const T &qMax(const T &a, const T &b)
2. 求最小值
const T &qMin(const T &a, const T &b)
3.求中间值
const T &qBound(const T &v1, const T &v2, const T &v3)
4.求列表容器的最值
QStringList list{"1", "3", "2"}; QString maxValue = *std::max_element(list.begin(), list.end()); QString minValue = *std::min_element(list.begin(), list.end());
5. 数组求最值
int array[] = {1, 5, 4, 3, 2, 0}; int maxValue = *std::max_element(array, array + sizeof(array)/sizeof(array[0])); int minValue = *std::min_element(array, array + sizeof(array)/sizeof(array[0]));
参考:http://www.qtbig.com/page/9/
长风破浪会有时,直挂云帆济沧海!
可通过下方链接找到博主
https://www.cnblogs.com/judes/p/10875138.html