CBRT has been

C++ Random number generator

Need some help fixing a computer problem, or just want to share a link to a program? Do it hear... From the PC to the CB!!!
Post Reply
User avatar
Deleted User 30222

C++ Random number generator

#390006

Post by Deleted User 30222 »

I have this number generator that i thought i would share. Not sure if there are any programmers here. It's written in simple C++

Code: Select all

#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std ;

int main()
{
  int i, j, k, nums[50] ;

  srand( (int) time(0) ) ;

  for( i = 1 ; i < 50 ; i++ ) nums[ i ] = i ;

  for( i = 1 ; i < 50 ; i++ )
  {
    j = ( (int) rand() % 49 ) + 1 ;
    k = nums[i]; nums[i]= nums[j] ; nums[j] = k ;
  }

  cout << "Your six lucky CBRT numbers are: " ;
  for( i = 1 ; i < 7 ; i++ ) cout << nums[i] << "  " ;

  // Uncomment the lines below to see all element values.
  // cout << endl << endl ;
  // for( i = 1 ; i < 50 ; i++ ) cout<< i <<": "<< nums[i] << endl ;

  return 0 ;
}
Beachbum24 wrote: Jan 15 2019, 19:44 Forgot to mention that this will pick your lucky six lottery numbers :) Good luck all
Last edited by Bozo on Jan 15 2019, 19:46, edited 1 time in total.
Reason: Combined double post
Post Reply