Commit a8b7d86b authored by Michael's avatar Michael

michael.davityan:exercise_07_40v7

parent 45eabe02
5 5
1 12
3 34
2 -3
4 7
9
5 5
5 11.25
11.5 -13.45
34.2 -12.64
23.7 23.7
45.65 1.56
7.5 5
6 badce
acdbes
...@@ -46,43 +46,42 @@ inputCharVector(std::vector<char> &vector, const int sizeOfVector) ...@@ -46,43 +46,42 @@ inputCharVector(std::vector<char> &vector, const int sizeOfVector)
int int
main() main()
{ {
const int BUFFER_SIZE = 10;
if (::isatty(STDIN_FILENO)) { if (::isatty(STDIN_FILENO)) {
std::cout << "Insert integers vector size and elements(size must be <= 10).\n" << "size: "; std::cout << "Insert integers vector size and elements.\n" << "size: ";
} }
int integersVectorSize; int integersVectorSize;
std::cin >> integersVectorSize; std::cin >> integersVectorSize;
if (integersVectorSize > BUFFER_SIZE) { if (integersVectorSize < 0) {
std::cerr << "Error 1: size must be less or equal than 10.\n"; std::cerr << "Error 1: size must be more than zero.\n";
return 1; return 1;
} }
std::vector<int> integersVector(BUFFER_SIZE); std::vector<int> integersVector(integersVectorSize);
inputNumericVector(integersVector, integersVectorSize); inputNumericVector(integersVector, integersVectorSize);
std::cout << "Minimum is: " << recursiveMinimum(integersVector, integersVectorSize - 1); std::cout << "Minimum is: " << recursiveMinimum(integersVector, integersVectorSize - 1);
std::cout << std::endl; std::cout << std::endl;
if (::isatty(STDIN_FILENO)) { if (::isatty(STDIN_FILENO)) {
std::cout << "Insert floating numbers vector size and elements(size must be <= 10).\n" << "size: "; std::cout << "Insert floating numbers vector size and elements.\n" << "size: ";
} }
int floatingVectorSize; int floatingVectorSize;
std::cin >> floatingVectorSize; std::cin >> floatingVectorSize;
if (floatingVectorSize > BUFFER_SIZE) { if (floatingVectorSize < 0) {
std::cerr << "Error 1: size must be less or equal than 10.\n"; std::cerr << "Error 1: size must be more than zero.\n";
return 1; return 1;
} }
std::vector<double> floatingVector(BUFFER_SIZE); std::vector<double> floatingVector(floatingVectorSize);
inputNumericVector(floatingVector, floatingVectorSize); inputNumericVector(floatingVector, floatingVectorSize);
std::cout << "Minimum is: " << recursiveMinimum(floatingVector, floatingVectorSize - 1); std::cout << "Minimum is: " << recursiveMinimum(floatingVector, floatingVectorSize - 1);
std::cout << std::endl; std::cout << std::endl;
if (::isatty(STDIN_FILENO)) { if (::isatty(STDIN_FILENO)) {
std::cout << "Insert characters vector size and elements(size must be <= 10).\n" << "size: "; std::cout << "Insert characters vector size and elements.\n" << "size: ";
} }
int charactersVectorSize; int charactersVectorSize;
std::cin >> charactersVectorSize; std::cin >> charactersVectorSize;
if (charactersVectorSize > BUFFER_SIZE) { if (charactersVectorSize < 0) {
std::cerr << "Error 1: size must be less or equal than 10.\n"; std::cerr << "Error 1: size must be more than zero.\n";
return 1; return 1;
} }
std::vector<char> charactersVector(BUFFER_SIZE); std::vector<char> charactersVector(charactersVectorSize);
inputCharVector(charactersVector, charactersVectorSize); inputCharVector(charactersVector, charactersVectorSize);
std::cout << "Minimum is: " << recursiveMinimum(charactersVector, charactersVectorSize - 2); std::cout << "Minimum is: " << recursiveMinimum(charactersVector, charactersVectorSize - 2);
std::cout << std::endl; std::cout << std::endl;
......
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