-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
106 lines (78 loc) · 2.72 KB
/
main.cpp
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
#include <iostream>
#include<conio.h>
#include<time.h>
#include<Windows.h>
#include"HienThi.h"
#include"NguoiChoi.h"
#include"KhoiTao.h"
#include"XuLy.h"
#include"Console.h"
using namespace std;
int main(){
int con1,con2,con3;
int bau,tom,cua,ca,nai,ga;
int tien=10,tien1,tien2,tien3;
char nhapSoMenu,numberHuongDan; //bien nhap vao lua chon trong menu
int dieuKienLap=1; //dieu kien duoc gan de tiep tuc choi
inMenu();
TextColor (13);
while(nhapSoMenu=getch()) {
if(nhapSoMenu=='1')
{
while(dieuKienLap==1)
{
clrscr(); //xoa man hinh
srand(time(NULL)); //sinh so ngau nhien cho xuc xac
con1 = khoiTao();
con2 = khoiTao();
con3 = khoiTao();
TextColor(12);
do{
cout<<" _________________________\n| Ban co "<<tien<<"$ de dat cuoc |\n|________________________|\n\n";
TextColor(11);
cout<<"Ban co 6 lua chon nhu sau: "<<endl;
chuyenTenBien(1); tom=datcuoc(tien);
chuyenTenBien(2); cua=datcuoc(tien); //dua ra loi dan voi cac bien tom,cua,ca,bau,nai,ga & dat cuoc vao moi bien tung ung
chuyenTenBien(3); ca=datcuoc(tien);
chuyenTenBien(4); bau=datcuoc(tien);
chuyenTenBien(5); nai=datcuoc(tien);
chuyenTenBien(6); ga=datcuoc(tien);
if(ga+tom+cua+ca+bau+nai>tien) {
cout<<"\nTong cac so ban vua nhap lon hon so tien ban dang co, hay nhap lai";
Sleep(2000);
clrscr();
}
} while (ga+ca+tom+cua+bau+nai > tien);
tien1=hamsosanh(con1,tom,cua,ca,bau,nai,ga);
tien2=hamsosanh(con2,tom,cua,ca,bau,nai,ga); //quy doi gia tri cua con1,con2,con3 lan luot sang tien1,tien2,tien3
tien3=hamsosanh(con3,tom,cua,ca,bau,nai,ga);
chuyenTenketQua(con1,con2,con3); //in ra ket qua
tinhtien(tien,tien1,tien2,tien3,tom,cua,ca,bau,nai,ga,con1,con2,con3); //tinh so tien sau 1 van choi
inKetQua(tien); //thong bao so tien hien co va loi ket
Sleep(3000);
clrscr();
inDiemHientai(tien); //in so diem hien tai
if(tien<1) return 0; //game over
TextColor (14);
cout<<"\n\n-->Ban co muon choi tiep khong?\n (Y/N):";
if(batDauChoi(luaChonChoi())==true)
dieuKienLap=1; //chuyen sang van tiep theo
else
{
//dieuKienLap=0; //thoat game
return 0;
}
}
}
else if(nhapSoMenu=='2'){
TextColor (11);
inHuongDan(); //in huong dan ra man hinh
nhapNumberHuongDan(numberHuongDan,nhapSoMenu); //nhap so bat ki de tro ve menu
clrscr();
inMenu(); //in menu ra man hinh sau khi thoat muc huong dan tro choi
}
else if(nhapSoMenu=='3') return 0; //thoat game
else nhapSoMenu; //nhap lai chinh xac so can chon tren menu
}
return 0;
}