C++ examples for Data Type:Random
Shifted and scaled random integers
#include <cstdlib> #include <iomanip> #include <iostream> int main(int argc, const char *argv[]) { for (int counter = 1; counter <= 20; ++counter) { std::cout << std::setw(10) << (1 + rand() % 6); // if counter divisible by 5, start a new line of output if (counter % 5 == 0) std::cout << std::endl; }//from w w w. ja v a 2 s . c o m return 0; }