Home > Software engineering >  Help small programming VB lottery in PPT
Help small programming VB lottery in PPT

Time:09-19

Seek help from a great god,,,
Have 1-120 number, a text box, a button, point a button text box randomly generated a number, the point again button text boxes randomly generated a number, and so on,
Each click the Numbers will not appear again, or click after 120 times, all the Numbers are finished, click on the 121th text box will not produce digital or program automatically end,

CodePudding user response:

1, create a collection
2120 the number of inserted into the collection
3, take two random number between 1 to 120, the two Numbers as a set of subscript take number from the collection, collection and two members exchange
4, repeat steps 3 several times later, to form a set of random Numbers 120
5, each click button, set the first member, and then delete the set this member
6, when after the 120 access note fault tolerance

CodePudding user response:

Must be repeated random, the so-called "no" is actually a shuffle, repeat random shuffle algorithm is used to refer to the following:
 # include & lt; stdio.h> 
#include
#include
Int d [6];
Int I, n, a, b, t;
C, int j;
Void main () {
Srand (time (NULL));
Printf (" shuffle 0.. N - 1 demo \ n ");
For (n=1; N<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
j=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
for (i=0; iFor (I=n; I> 0; I -) {/* disturb 0 ~ */n - 1
A=I - 1; B=rand () % I;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
for (i=0; iprintf("\n");
}
}
Printf (" shuffle 1.. N demo \ n ");
For (n=1; N<=5; N++) {/* (1 ~ 5 */
Printf (" _____n=% d_____ \ n ", n);
j=1;
For (c=1; C<=n; C + +) j=j * c;/* j for n! */
J *=n * 2;
For (c=1; C<=j; C + +) {/* test n * 2 * n! Time */
For (I=1; i<=n; I++) d [I]=I;/* fill in 1 ~ n */
For (I=n; I> 1; I -) {/* disturb 1 ~ n */
A=I; B=rand () % I + 1;
If (a! A=b) {t=d [a]; D [a] [b]=d; D [b]=t; }
}
Printf (" % 4 d: ", c);
For (I=1; i<=n; I++) printf (" % d ", d [I]);
printf("\n");
}
}
}

CodePudding user response:

reference 1st floor chewinggum response:
1, create a collection
2120 the number of inserted into the collection
3, take two random number between 1 to 120, the two Numbers as a set of subscript take number from the collection, collection and two members exchange
4, repeat steps 3 several times later, to form a set of random Numbers 120
5, each click button, set the first member, and then delete the set this member
6, when after the 120 access note fault-tolerant

Should be a little bit more simple, more do not need to order, get rid of step three, four, five, each time you access, if the collection of the count=0, and then exit, if count> 0, randomly generated directly index between 0 ~ count - 1, take the corresponding element index, and deleted after output,

CodePudding user response:

For the points

CodePudding user response:

Click on the 120 times? I'm afraid you hand to cramp
  • Related