1 làm xong caro có post ko ta??? 2009-11-11, 19:14
tranhanhuy
Thành Viên
làm xong bài caro 2 người chơi rồi có nên post ko ta???
chưa làm bài caro người vs máy
chưa làm bài caro người vs máy
https://sourceforge.net/projects/hanhuy/files/linh%20tinh/%5Bdemo%5D%20TroChoiCaro.rar/download
bool KtraTruongHopNgang(int m_BanCo[CotDong][CotDong], int NguoiChoiThu, int ViTriCot, int ViTriDong)
{
int flag1=0; //mac dinh la sai
int flag2=1; //mac dinh la dung
int flag3=0; //mac dinh la sai
if (ViTriCot-1>=0)
{
if (m_BanCo[ViTriDong][ViTriCot-1] == NguoiChoiThu)
{
flag1=1;
}
}
for (int j=ViTriCot; j<ViTriCot+5; j++)
{
if (j<CotDong)
{
if (m_BanCo[ViTriDong][j] != NguoiChoiThu)
{
flag2 = 0;
return false;
}
}
else
{
return false;
}
}
if (ViTriCot+5<CotDong)
{
if (m_BanCo[ViTriDong][ViTriCot+5]==NguoiChoiThu)
{
flag3 = 1;
}
}
if (flag1 == 0 || flag3==0)
{
return true;
}
return false;
}
bool KtraTruongHopDoc(int m_BanCo[CotDong][CotDong], int NguoiChoiThu, int ViTriCot, int ViTriDong)
{
int flag1=0; //mac dinh la sai
int flag2=1; //mac dinh la dung
int flag3=0; //mac dinh la sai
if (ViTriDong-1>=0)
{
if (m_BanCo[ViTriDong-1][ViTriCot] == NguoiChoiThu)
{
flag1=1;
}
}
for (int j=ViTriDong; j<ViTriDong+5; j++)
{
if (j<CotDong)
{
if (m_BanCo[j][ViTriCot] != NguoiChoiThu)
{
flag2 = 0;
return false;
}
}
else
{
return false;
}
}
if (ViTriDong+5<CotDong)
{
if (m_BanCo[ViTriDong+5][ViTriCot]==NguoiChoiThu)
{
flag3 = 1;
}
}
if (flag1 == 0 || flag3==0)
{
return true;
}
return false;
}
bool KtraTruongHopCheoTheoChinh(int m_BanCo[CotDong][CotDong], int NguoiChoiThu, int ViTriCot, int ViTriDong)
{
int flag1=0; //mac dinh la sai
int flag2=1; //mac dinh la dung
int flag3=0; //mac dinh la sai
if (ViTriCot-1>=0 && ViTriDong-1>=0)
{
if (m_BanCo[ViTriDong-1][ViTriCot-1] == NguoiChoiThu)
{
flag1=1;
}
}
for (int i=ViTriDong,j=ViTriCot; i<ViTriDong+5 && j<ViTriCot+5; i++,j++)
{
if (i<CotDong && j<CotDong)
{
if (m_BanCo[i][j] != NguoiChoiThu)
{
flag2 = 0;
return false;
}
}
else
{
return false;
}
}
if (ViTriDong+5<CotDong && ViTriCot+5<CotDong)
{
if (m_BanCo[ViTriDong+5][ViTriCot+5]==NguoiChoiThu)
{
flag3 = 1;
}
}
if (flag1 == 0 || flag3==0)
{
return true;
}
return false;
}
bool KtraTruongHopCheoTheoPhu(int m_BanCo[CotDong][CotDong], int NguoiChoiThu, int ViTriCot, int ViTriDong)
{
int flag1=0; //mac dinh la sai
int flag2=1; //mac dinh la dung
int flag3=0; //mac dinh la sai
if (ViTriCot+1>=0 && ViTriDong-1>=0)
{
if (m_BanCo[ViTriDong-1][ViTriCot+1] == NguoiChoiThu)
{
flag1=1;
}
}
for (int i=ViTriDong,j=ViTriCot; i<ViTriDong+5 && j>ViTriCot-5; i++,j--)
{
if (i<CotDong && j<CotDong)
{
if (m_BanCo[i][j] != NguoiChoiThu)
{
flag2 = 0;
return false;
}
}
else
{
return false;
}
}
if (ViTriDong+5<CotDong && ViTriCot-5<CotDong)
{
if (m_BanCo[ViTriDong+5][ViTriCot-5]==NguoiChoiThu)
{
flag3 = 1;
}
}
if (flag1 == 0 || flag3==0)
{
return true;
}
return false;
}
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|