/ Published in: C++
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
#include <iostream>
#include <cstdlib>
#include <ctime>
int main(int argc, char *argv[]){
if(argc != 3){
cout << "Usage: " << endl;
cout << " rand [int x] [int y]" << endl;
cout << " [x] = highest possible value of a random number" << endl;
cout << " [y] = quantity of random numbers created" << endl << endl;
exit(1);
}
long int M = atoi(argv[1]);
int quantity = atoi(argv[2]);
srand(time(NULL));
for(int count = 1; count <= quantity; ++count)
cout << (((int)(((double)rand()/(double)(RAND_MAX+1))*M))*-1)+1 << endl;
return 0;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                