#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
std::vector<int> GeneratorOfRandNums(int *userInput) {
std::vector<int> tempVector;
srand(time(0));
for (int i = 0; i < *userInput; i++) {
tempVector.push_back(rand());
}
return tempVector;
}
void PrintGeneratedVector(std::vector<int> &userInput) {
for (int i = 0; i < userInput.size(); i++) {
std::cout << i << ": " << userInput[i] << std::endl;
}
}
void PrintPair(std::pair<int, int> &userInput) {
std::cout << "Minimum value: " << userInput.first << std::endl;
std::cout << "Maximum value: " << userInput.second << std::endl;
}
std::pair<int, int> GetMinMaxValue(std::vector<int> &userInput) {
std::pair <int, int> resultMinAndMaxOfVector;
int minValue = *std::min_element(userInput.begin(), userInput.end());
int maxValue = *std::max_element(userInput.begin(), userInput.end());
resultMinAndMaxOfVector = std::make_pair(minValue, maxValue);
return resultMinAndMaxOfVector;
}
int main() {
int userInput;
std::vector<int> vectorOfRandomNums;
std::pair<int, int> pairOfMinAndMax;
std::cout << "Input vector length: " << std::endl;
std::cin >> userInput;
vectorOfRandomNums = GeneratorOfRandNums(&userInput);
if (!vectorOfRandomNums.empty()) {
pairOfMinAndMax = GetMinMaxValue(vectorOfRandomNums);
PrintPair(pairOfMinAndMax);
PrintGeneratedVector(vectorOfRandomNums);
}
else {
std::cout << "Vector of generated numbers is null!\n";
}
return 0;
}