There are many alternatives to
ctime that have a richer, more flexible, type-safe interface, e.g.,
boost.Chrono, or
std::chrono.
If you decide you want more specific sampling, e.g., from a specific distribution from a specified range, consider
boost.Random https://theboostcpplibraries.com/boost.random.
Note's about your above code sample:
1. Use
std::array's rather than c-array's for type-safety when accessing/storing data.
2. Consider alternatives to
ctime that provide specific types that accomplish the same results.
3. Avoid nested for-loops utilising counters of the same name (here, its a typo however).
4. Consider manipulating the output stream once outside the loop then resetting it at the end (if desired).
5. Be explicit with namespace scope (i.e.,
std::cout, not
using namespace std;...cout << ....
6. Post-incrementation of counters brings you nothing here, just a needless copy. Use the pre-increment op.