30/09/2018, 20:35
Ai góp ý giúp em với?
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
#include<windows.h>
int main()
{
int n;
int sotienbd = 100000;
int sotienconlai;
int check;
int ca =0;
int nai=0;
int bau=0;
int ga=0;
int tom=0;
int cua=0;
printf(" GAME BAU CUA CA - made by Dang Quoc Huy");
huy:
printf("
MENU");
printf("
1 - Dat cuoc");
printf("
2 - Play");
printf("
3 - Exit");
do{
printf("
Nhap lua chon chua ban :");
scanf("%d", &n);
if (n > 3 || n < 1)
printf("
Lua chon khong hop le!!!");
} while (n < 1 || n > 3);
if (n == 1)
{
if (sotienbd < 0)
{
printf("
So tien con lai cua ban la: %d", sotienconlai);
}
else
{
printf("So tien ban dau cau ban: %d", sotienbd);
}
printf("
Ban dat cuoc cho ca :");
scanf("%d", &ca);
check = 1;
sotienbd -= ca;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
ca = 0;
printf("
So tien con lai cua ban la: %d", sotienbd);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
printf("Ban dat cuoc cho nai :");
scanf("%d", &nai);
check = 2;
sotienconlai = sotienbd;
sotienbd -= nai;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
nai = 0;
printf("
So tien con lai cua ban la: %d", sotienconlai);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
printf("Ban dat cuoc cho bau :");
scanf("%d", &bau);
check = 3;
sotienconlai = sotienbd;
sotienbd -= bau;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
bau = 0;
printf("
So tien con lai cua ban la: %d", sotienconlai);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
printf("Ban dat cuoc cho ga :");
scanf("%d", &ga);
check = 4;
sotienconlai = sotienbd;
sotienbd -= ga;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
ga = 0;
printf("
So tien con lai cua ban la: %d", sotienconlai);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
printf("Ban dat cuoc cho tom :");
scanf("%d", &tom);
check = 5;
sotienconlai = sotienbd;
sotienbd -= tom;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
tom = 0;
printf("
So tien con lai cua ban la: %d", sotienconlai);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
printf("Ban dat cuoc cho cua : ");
scanf("%d", &cua);
check = 6;
sotienconlai = sotienbd;
sotienbd -= cua;
if (sotienbd < 0)
{
printf("
Ban khong du tien cuoc");
cua = 0;
printf("
So tien con lai cua ban la: %d", sotienconlai);
printf("
Ban muon dat cuoc tiep(bam 1) hay la play(bam 2): ");
goto huy;
}
else
{
printf("
So tien con lai cua ban la: %d", sotienconlai);
goto huy;
}
}
if (n == 2)
{
printf("
BAT DAU DO XUC SAC!!!");
int x;
int sotienthuong = 0;
int sotienlucsau = 0;
for (int i = 1; i <= 3; i++)
{
printf("
XUC SAC THU %d", i);
Sleep(1000);
//srand(time(0));
int x;
x = 1 + rand() % 6;
srand(time(0));
if (x == 1)
{
printf("
Ca");
sotienthuong += ca;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (x == 2)
{
printf("
Nai");
sotienthuong += nai;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (x == 3)
{
printf("
Bau");
sotienthuong += bau;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (x == 4)
{
printf("
Ga");
sotienthuong += ga;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (x == 5)
{
printf("
Tom");
sotienthuong += tom;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (x == 6)
{
printf("
Cua");
sotienthuong += cua;
printf("
So tien thang duoc : %d", sotienthuong);
sotienlucsau = sotienthuong + sotienconlai;
///printf("
So tien sau khi choi: %d ", sotienlucsau);
}
//printf("
So tien sau khi choi: %d ", sotienlucsau);
}
printf("
So tien sau khi choi: %d ", sotienlucsau);
}
if (n == 3)
{
return 0;
}
getch();
return 0;
}
Bài liên quan
em mới làm ra game bầu cua này, mong mọi người góp ý. Còn 2 vấn đề là lúc mới đầu vào mà chọn số 2 sẽ lỗi ngay và khi em chọn release trong visual thì bị lỗi này