/****************************
To verify the accuracy, remove the commented out part
****************************/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUMB1 15
#define NUMB2 5
/****************************
NUMB1: Determine how many consecutive random numbers to generate
NUMB2: Panning the range of random numbers
****************************/
int main () {
int f = 0;
int cq=1000;
int C[NUMB1] = {0}; /** is used to verify that a random number exists and is initialized to 0 **/
int CNT[NUMB1] = {0}; /** take out the random number **/
int count = 0; /** is used to ensure that the program ends when it is finished **/
Srand (Time (NULL));/** Temporal seed **/
while (cq--) {
while (1)
{
int r = rand ()%NUMB1; /** produces a numb1 random number, ranging from 0 to numb1-1**/
if (++c[r] > 1)/** If there is already a random number and the number of the array is the same, the number is reset **/
Continue
Else
{
Cnt[count] = r + numb2; /**CNT an order fetch number
Numb determine the amplitude, or the angle of the translation
**/
printf ("%2d", Cnt[count]); /**, starting from scratch **/
if (++count >= numb1)/** 1<+>1**/
Break
}
// }
/** count = 0;
printf ("\ n");
for (f = 0;f<numb1;f++) {
c[f]=0;
}**/
}
return 0;
}
Perfect acquisition of random numbers