Skip to content

Instantly share code, notes, and snippets.

@gao-sun gao-sun/lottery.cpp

Created Mar 25, 2020
Embed
What would you like to do?
Lottery
#include <cstdio>
#include <cmath>
#include <cstdlib>
int hash[10000] = {0};
int main ()
{
float index;
int count;
scanf("%f%d", &index, &count);
srand(floor(index * index));
for (int i = 0; i < 50; ++ i) {
int next = 0;
while (!next) {
int tmp = rand() % count + 1;
if (!hash[tmp]) {
next = tmp;
hash[tmp] = 1;
}
}
printf("%d\n", next);
}
return 0;
}
@gao-sun

This comment has been minimized.

Copy link
Owner Author

gao-sun commented Mar 27, 2020

➜ ./lottery
2772.2 368
9
165
117
73
182
290
71
314
308
5
129
343
46
162
262
279
350
329
185
63
108
8
47
253
179
12
55
128
35
144
254
98
147
154
1
306
226
49
84
297
138
203
316
194
298
11
281
215
365
192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.