refine the lottery algorithm to reduce its computational complexity
Fork of app_board-Lottery by
Diff: main.cpp
- Revision:
- 2:254e72dcfb52
- Parent:
- 1:c9dba148697b
- Child:
- 3:d327dd543579
--- a/main.cpp Wed Jul 20 09:19:00 2016 +0000 +++ b/main.cpp Wed Jul 20 11:59:33 2016 +0000 @@ -76,7 +76,7 @@ // Generate non-repeat users for(int i=0;i<GIFT_MAXCNT;i++){ while(1){ - int rand_num = rand()%MAN_MAXCNT; + int rand_num = rand()%MAN_MAXCNT+1; int repeat=0; for(int j=0;j<i;j++){ if( gift[j] == rand_num ) repeat=1;