C++ Random number generator
Posted: Aug 26 2018, 17:59
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