Last active
September 28, 2023 06:04
-
-
Save maneesh29s/51e1498817f2ce71be9d14a224d162fe to your computer and use it in GitHub Desktop.
Random Distribution Generator using standard library methods (c++17 and above). Random data is generated and stored in a 2D array of size 4x3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| #include <chrono> | |
| #include <cstdlib> | |
| #include <iostream> | |
| #include <random> | |
| using Vec3D = std::array<float, 3>; | |
| int main() { | |
| std::array<Vec3D, 4> arr; | |
| std::random_device rd; | |
| std::mt19937 generator(rd()); | |
| std::uniform_real_distribution<float> distribution(0.f, 1.f); | |
| for (std::size_t i = 0; i < arr.size(); ++i) { | |
| arr[i] = {distribution(generator), distribution(generator), | |
| distribution(generator)}; | |
| std::cout << arr[i][0] << " " << arr[i][1] << " " << arr[i][2] << std::endl; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment