fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <random>
  4. #include <time.h>
  5. using namespace std;
  6. int main( ){
  7. struct tm a = {0,0,0,1,0,50}; /* Jan 1, 1950 */
  8. struct tm b = a;
  9. time_t x = mktime(&a);
  10. random_device rd; // non-deterministic generator
  11. mt19937 gen(rd());
  12. uniform_int_distribution<> dist(1,1000); // distribute results between 1 and 6 inclusive.
  13.  
  14. for (int n = 0; n < 5; ++n) {
  15.  
  16. b.tm_mday = a.tm_mday+dist(gen);
  17. time_t y = mktime(&b);
  18. cout<<put_time(&b, "%d-%m-%Y")<<endl ;
  19. }
  20. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
23-06-1950
30-09-1952
10-07-1954
16-11-1954
23-08-1956