-
Notifications
You must be signed in to change notification settings - Fork 0
/
tombola.c
53 lines (39 loc) · 861 Bytes
/
tombola.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
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
/*Programma per la estrazione di 90 numeri di tombola.*/
int
main(int argc,char **argv) {
int n, m, nread, a=1;
int tab[91];
char buffer[128];
pid_t pid = getpid(); /* Get our process ID */
srand((unsigned)pid);
for (n=1; n<=90; n++ ) {
tab[n] = 0;
}
for ( n=1; n<=10; n++ ) {
printf("\n");
fflush(stdout);
}
m = 0;
printf("Premi <Invio> per un'estrazione o Ctrl-C per uscire.\n");
while (a) {
n = rand() % 90 + 1; /* 1 to 90 */
/* printf("%d\t%d.\n", n, tab[n]);*/
printf("");
if (tab[n]) {
}
else {
tab[n] = 1;
m++;
nread = read(0,buffer,128);
printf("L'estrazione numero %d e' \t%d.\n", m, n);
for ( n=1; n<=10; n++ ) {
printf("\n");
fflush(stdout);
}
};
if (m > 89) {a = 0;}
}
}