Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ find minimum value in vector

#include <iostream>
#include <algorithm> 
#include <vector> 
using namespace std;

int main()
{
    vector<int> a = {1,5,6,7,8,3};
    cout << *min_element(a.begin(), a.end());
    return 0;
}
Comment

minimum and maximum value of a vector in C++

#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
    std::vector<int> v = {2, 1, 3, 6, 7, 9, 8};
 
    int max = *max_element(v.begin(), v.end());
    int min = *min_element(v.begin(), v.end());
 
    std::cout << min << ", " << max << std::endl;        // 1, 9
 
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: ue4 spawn actor c++ 
Cpp :: jupyter lab use conda environment 
Cpp :: lpcwstr to string c++ 
Cpp :: UNIX c++ delay 
Cpp :: clear buffer memory in c / c++ 
Cpp :: check if directory exists cpp 
Cpp :: c++ get length of array 
Cpp :: c++ bold text 
Cpp :: map key exists c++ 
Cpp :: struct and return functions in c++ 
Cpp :: c++ convert binary string to decimal 
Cpp :: angle to vector2 godot 
Cpp :: file descriptor linux c++ 
Cpp :: error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ 
Cpp :: insert at position in vector c++ 
Cpp :: precision of fixed in c++ 
Cpp :: program to convert int to int array c++ 
Cpp :: c++ throw exception 
Cpp :: call of overloaded ‘swap(int&, int&)’ is ambiguous 
Cpp :: c++ program to add two numbers using function 
Cpp :: how to get a word from file c++ 
Cpp :: finding size of columns and rows in 2d vector c++ 
Cpp :: binary exponentiation modulo m 
Cpp :: how to sort a vector in descending order in c++ 
Cpp :: c++ program to calculate discount 
Cpp :: integer type validation c++ 
Cpp :: infinite loop c++ 
Cpp :: c++ get time 
Cpp :: 2d vector cpp 
Cpp :: how to make a random number in c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =