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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
| #include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>
class Gran { protected: int ochko; };
class Kosti:public Gran
{
char count[6];
public:
void vivod();
void vvod(char COUNT[6],int OCHKO);
int ochki1();
int ochki2();
int random1();
int random2();
void rand_ochki1();
void rand_ochki2();
void draw1();
void draw2();
void podschet();
void menu();
void vivodCount();
// void pod();
};
int kol=2;
Kosti Zariki[6];
void Kosti::draw1()
{ int i;
//outtextxy(5,3,"Gamer 1");
window(5,5,14,10);
textbackground(2);
clrscr();
gotoxy(1,1);
rand_ochki1();
window(16,5,25,10);
textbackground(2);
clrscr();
gotoxy(1,1);
rand_ochki2();
i=random1()+random2();
cout<<" Chet="<<i;
};
void Kosti::draw2()
{ int j;
//outtextxy(30,3,"Gamer 2");
window(30,5,39,10);
textbackground(2);
clrscr();
gotoxy(1,1);
rand_ochki1();
window(41,5,50,10);
textbackground(2);
clrscr();
gotoxy(1,1);
rand_ochki2();
j=random1()+random2();
cout<<" Chet="<<j;
}
/*
int Kosti::ochki1()
{ int buf,i;
buf=0;
i=random1();
buf=buf+Zariki[i].ochko;
return(buf);
}
int Kosti::ochki2()
{ int buf,i;
buf=0;
i=random2();
buf=buf+Zariki[i].ochko;
return(buf);
}
*/
void Kosti::menu()
{ int num;
cin>>num;
switch(num)
{ case 1: textcolor(BLACK); draw1();
menu();
case 2: textcolor(BLACK); draw2();
menu();
case 0: exit(0);
// case 9: rand_ochki1(); gotoxy(1,1); cout<<"ochki 000000"<<ochki1()<<endl;
// menu();
default: cout<<"\n Zanovo"<<endl; getch(); menu();
}
}
void Kosti::rand_ochki1()
{ int i;
i=random1();
Zariki[i].vivodCount();
endl;
}
void Kosti::rand_ochki2()
{ int i;
i=random2();
Zariki[i].vivodCount();
endl;
}
int Kosti::random1()
{ int i;
q:
randomize();
i=rand()%5;
if(i>=5) goto q;
return(i);
}
int Kosti::random2()
{ int j;
q:
randomize();
j=rand()%6;
if(j>=6) goto q;
return(j);
}
void Kosti::vvod(char COUNT[6], int OCHKO)
{
strcpy(count,COUNT);
ochko=OCHKO;
}
/*void Kosti::vivod()
{
cout<<"\n Kosti ="<<count<<"-"<<ochko;
} */
void Kosti::vivodCount()
{
cout<<count;
}
main()
{
/*int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"");*/
// int sv;
Kosti ob1;
textcolor(RED);
highvideo();
clrscr();
gotoxy(10,3);
cout<<"First gamer";
gotoxy(35,3);
cout<<"Second gamer";
Zariki[1].vvod("1",1);
Zariki[2].vvod("2",2);
Zariki[3].vvod("3",3);
Zariki[4].vvod("4",4);
Zariki[5].vvod("5",5);
Zariki[6].vvod("6",6);
cout<<"\n\n\n\n\n\n\n\n\n\n\n Enter 1 for first gamer";
cout<<"\n Enter 2 for second gamer"<<endl;
ob1.menu();
getch();
return(0);
} |