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
JetSetter
Moderator
Moderator
Posts: 1,445
Joined: January 6th, 2018, 8:23 pm
Handle: JetSetter/822
Real Name: Greg
Antenna: 11m Dipole, PAT-12, Browning BR-28
Radio: RCI-2995DXCF
Contact:

C++ Random number generator

#390006

Post by JetSetter »

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: January 15th, 2019, 7:44 pm Forgot to mention that this will pick your lucky six lottery numbers :) Good luck all
Last edited by on January 15th, 2019, 7:46 pm, edited 1 time in total.
Reason: Combined double post
Image

"822" Were Alive and Kickin'
From the land of Lincoln
Post Reply