-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrand.c
executable file
·69 lines (48 loc) · 930 Bytes
/
rand.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
//int init=0;
int init=0;
//dimiourgia tyxaiou arithmou
double GetRand()
{
int i;
while(init==0)
{
srand((unsigned)(time(0)));
init=1;
}
double rr = ( ((double)rand() / ((double)(RAND_MAX))*18+1.0));
return(rr);
}
main()
{
double rr;
int i;
// initrand();
for(i=0;i<50;i++)
{
rr = (int)GetRand();
//double x=rr*M;
printf("%lf\n",rr);
}
}
/*
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
double iSecret, iGuess;
srand ( time(NULL) );
iSecret = rand() % 10 + 1;
do {
printf ("Guess the number (1 to 10): ");
scanf ("%d",&iGuess);
if (iSecret<iGuess) puts ("The secret number is lower");
else if (iSecret>iGuess) puts ("The secret number is higher");
} while (iSecret!=iGuess);
puts ("Congratulations!");
return 0;
}
*/