added example to make 128 random numbers

This commit is contained in:
2025-02-01 17:37:09 -05:00
parent bcaf45e1bc
commit e7fb6724b0

View File

@@ -1,4 +1,5 @@
#include <iostream>
#include <vector>
#include "ReUnirand/unirand.hpp"
int main() {
@@ -17,5 +18,23 @@ int main() {
float randomValue = rng.uni();
std::cout << "Random Number: " << randomValue << std::endl;
std::cout << "The result should be: 0.687533" << std::endl;
std::cout << std::endl << "And now for 128 random numders:" << std::endl;
// Define the size of the array.
const int arraySize = 128;
// Create a vector to store the 128 random numbers.
std::vector<float> randomNumbers(arraySize);
// Generate random numbers and store them in the vector.
for (int i = 0; i < arraySize; ++i) {
randomNumbers[i] = rng.uni();
}
// Output the random numbers.
for (int i = 0; i < arraySize; ++i) {
std::cout << "Random number " << i << ": " << randomNumbers[i] << std::endl;
}
return 0;
}