Commit d52f5924 authored by Michael's avatar Michael

exercise_07_40v10

parent f5341f69
......@@ -6,9 +6,9 @@
#include <limits>
template <typename T>
T
recursiveMinimum(const std::vector<T>& vector, const int sizeOfVector,
T minimum = std::numeric_limits<T>::max())
T
recursiveMinimum(const std::vector<T>& vector, const int sizeOfVector,
T minimum = std::numeric_limits<T>::max())
{
assert(sizeOfVector >= 0);
if (0 == sizeOfVector) {
......@@ -21,8 +21,8 @@ recursiveMinimum(const std::vector<T>& vector, const int sizeOfVector,
}
template <typename T>
void
inputVector(std::vector<T>& vector, const int sizeOfVector)
void
inputVector(std::vector<T>& vector, const int sizeOfVector)
{
assert(sizeOfVector > 0);
for (int index = 0; index < sizeOfVector; ++index) {
......@@ -38,20 +38,20 @@ main()
{
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert integers vector size and elements.\n" << "size: ";
}
}
int integersVectorSize;
std::cin >> integersVectorSize;
if (integersVectorSize < 0) {
std::cerr << "Error 1: size must be more than zero.\n";
return 1;
}
}
std::vector<int> integersVector(integersVectorSize);
inputVector(integersVector, integersVectorSize);
std::cout << "Minimum is: " << recursiveMinimum(integersVector, integersVectorSize - 1);
std::cout << std::endl;
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert floating numbers vector size and elements.\n" << "size: ";
}
}
int floatingVectorSize;
std::cin >> floatingVectorSize;
if (floatingVectorSize < 0) {
......@@ -64,13 +64,13 @@ main()
std::cout << std::endl;
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert characters vector size and elements.\n" << "size: ";
}
}
int charactersVectorSize;
std::cin >> charactersVectorSize;
if (charactersVectorSize < 0) {
std::cerr << "Error 1: size must be more than zero.\n";
return 1;
}
}
std::vector<char> charactersVector(charactersVectorSize);
inputVector(charactersVector, charactersVectorSize);
std::cout << "Minimum is: " << recursiveMinimum(charactersVector, charactersVectorSize - 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment