-
Notifications
You must be signed in to change notification settings - Fork 30
/
tambola.c
79 lines (70 loc) · 1.07 KB
/
tambola.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
70
71
72
73
74
75
76
77
78
79
/*
A rudimentary tambola game that plays itself.
*/
#include<conio.h>
#include<stdlib.h>
#include<time.h>
void reprint();
int tic1[10];
int tic2[10];
int i=0,j=0;
void main()
{
int x=0,n=0,p1=0,p2=0,a=0,p=0,done[100];
srand(time(NULL));
while(1)
{
n++;
done[p]=0;}
clrscr();
for(j=0;j<100;j=j+10)
{
tic1[i]=((rand())%10)+j;
tic2[i]=((rand())%10)+j;
i++;
}
reprint();
for(n=0;n<100;n++)
{
x=rand()%100;
done[x]=1;
printf("\n\nNUMBER : %d",x);
for(a=0;a<10;a++)
{
if(x==tic1[a])
{
p1++;
printf("\nP1 has %d.",x);
delay(500);
}
if(x==tic2[a])
{
p2++;
printf("\nP2 has %d.",x);
delay(500);
}
}
printf("\n");
for(p=0;p<100;p++) {if (done[p]) printf("%d ",p);
if(p1==10) {printf("\nP1 WINS!!!");getch();exit(0);}
if(p2==10) {printf("\nP2 WINS!!!");getch();exit(0);}
}
delay(200);reprint();
}
getch();
}
/* reprint */
void reprint()
{
clrscr();
printf("\nPlayer 1 : ");
for(i=0;i<10;i++)
{
printf("%d ",tic1[i]);
}
printf("\nPlayer 2 : ");
for(i=0;i<10;i++)
{
printf("%d ",tic2[i]);
}
}