33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
/// @file
|
|
/// @brief Task1: "single-file" excutable C++ program
|
|
|
|
/// @todo Include standard library headers as needed
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
/// @brief Find the minimum value in a sequence of integer values
|
|
/// @param data Sequence of values stored in a std::vector<int> (assertion: sequence is not empty )
|
|
/// @return Minimum value in the sequence
|
|
int min(const std::vector<int>& data) {
|
|
int min = data[0];
|
|
for (int i = 1; i < data.size(); i++) {
|
|
if (data[i] < min) {
|
|
min = data[i];
|
|
}
|
|
}
|
|
return min;
|
|
}
|
|
|
|
/// @brief main function (entry point) conducting the following tasks in this order:
|
|
/// - create and prepare a local variable of type std::vector<int>
|
|
/// holding a sequence of 5 values in this order: -10, 20, 100, -1024, 2048
|
|
/// - call your function 'min' and provide the prepared variable as argument to the call
|
|
/// - capture the result of your function call in a local variable and print it to the console
|
|
|
|
int main() {
|
|
std::vector<int> data = {-10, 20, 100, -1024, 2048};
|
|
int min_value = min(data);
|
|
std::cout << "The minimum value is: " << min_value << std::endl;
|
|
return 0;
|
|
} |