-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.c
52 lines (49 loc) · 1.37 KB
/
random.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i, z, g, minlimit, maxlimit;
char name[20];
srand(time(NULL));
minlimit=0; // Minimum number possible for random selection
maxlimit=100; // Maxiumum number possible for random selection
printf("±êÍÔQ[Å·B\n");
printf("¨¼Oͽŷ©HF");
gets(name);
printf("±ñÉ¿ÍA");
for (z=0; z<strlen(name); z++)
{
printf("%c",name[z]);
}
printf("³ñB");
printf("\né§ÌÔð¢¢ÄÄÝĺ³¢ ! (%d-%d)\n" , minlimit, minlimit+maxlimit);
printf("pÓÍ¢¢Å·©H");
i = rand()*123456789 / (RAND_MAX + 1); // Randomize
z=0;
g=0;
i = (rand() * (maxlimit+1-minlimit) / (RAND_MAX + 1)) + minlimit; // select number
do {
printf("\né§Ôͽŵ天H");
scanf("%d",&z);
if (z>=minlimit && z<=minlimit+maxlimit) {
g++;
if (z>i) {
printf("\n¢ß¬éI");
}
if (z<i) {
printf("\ná¢ß¬éI");
}
}
} while (z!=i);
printf("¨ßÅƤ");
for (z=0; z<strlen(name); z++)
{
printf("%c",name[z]);
}
printf("³ñ!!");
printf("\nâÁ½ËI%dñÚÉūܵ½I", g);
printf("\né§ÔÍ%dŵ½I", i);
return 0;
}