1个回答
展开全部
#include<ctype.h>
#include<stdio.h>
#include<dos.h> #include<conio.h> #include<ctype.h> #include<bios.h>
#define SHURU 1
#define FANGXIANG 2
#define WUXIAO 0
#define TUICHU 3
/************************ ****************************/
static int ii = 0, jj = 0, wanj ia = 1;
/************************ ****************************/
void hqp(int a[][20], int);
int anjian(char an);
int panduan(int a[][20]);
void pingmu(void);
void guangbiaoyd(char an)
void jh(int a[][20]);
/************************ ****************************/
void main()
{
int a[20][20] = { 0 }, tuichu = 0, ying;
char an;
hqp(a, 0);
pingmu();
while (1)
{
ying = panduan(a);
if (ying != 0)
hqp(a, ying);
an = getch();
switch (anjian(an))
{
case TUICHU:
clrscr();
tuichu = 1;
break;
case FANGXIANG:
guangbiaoy d(an);
break;
case SHURU:
switch (ying)
{
case 1:
hqp(a, 1);
tuichu = 1;
break;
case 2:
hqp(a, 2);
tuichu = 1;
break;
case 0:
jh(a);
break;
}
break;
case WUXIAO:
break;
}
hqp(a, 0);
pingmu();
if (tuichu == 1)
break;
}
} /************************ ****************************/
void hqp(int a[][20], int)
{
int i, j;
clrscr();
if (y != 0)
{
textcolor(RED);
printf("WAN JIA %d SHENG LI! ! ! ! ! \n", y);
}
for (i = 0; i < 20; i++)
{
for (j = 0; j < 20; j++)
{
switch (a[i][j])
{
case 1:
textcolor(YELLOW) putch('X');
break;
case 2:
textcolor(BLUE);
putch('0');
break;
case 0:
textcolor(GREEN);
if (j == 0)
{
if (i == 0)
{
putch(0xda);
break;
}
if (i == 19)
{
putch(0xc0);
break;
}
putch(0xc3);
break;
}
if (j == 19)
{
if (i == 0)
{
putch(0xbf);
break;
}
if (i == 19)
{
putch(0xd9);
break;
}
putch(0xb4);
break;
}
if (i == 0 && j != 0 && j != 19)
{
putch(0xc2);
break;
}
if (i == 19 && j != 0 && j != 19)
{
putch(0xc1);
break;
}
putch(0xc5);
break;
}
}
printf("\n");
}
} /************************ **************************** *************/
int anjian(char an)
{
if (an == 32 || an == 13)
return (SHURU);
else if (an == 'a' || an == 'w' || an == 's' || an == 'd' || an == 'j'
|| an == 'i' || an == 'k' || an == 'l')
return (FANGXIANG);
else if (an == 27)
return (TUICHU);
else
return (WUXIAO);
} /************************ **************************** **************/
int panduan(int a[][20])
{
int i, j;
for (i = 0; i < 20; i++)
{
for (j = 0; j < 15; j++)
{
if (a[i][j] == 1 && a[i][j + 1] = = 1 && a[i][j + 2] == 1
&& a[i][j + 3] = = 1 && a[i][j + 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i][j + 1] = = 2 && a[i][j + 2] == 2
&& a[i][j + 3] = = 2 && a[i][j + 4] == 2)
return (2);
}
}
for (i = 0; i < 15; i++)
{
for (j = 0; j < 20; j++)
{
if (a[i][j] == 1 && a[i + 1][j] = = 1 && a[i + 2][j] == 1
&& a[i + 3][j] = = 1 && a[i + 4][j] == 1)
return (1);
else if (a[i][j] == 2 && a[i + 1][j] = = 2 && a[i + 2][j] == 2
&& a[i + 3][j] = = 2 && a[i + 4][j] == 2)
return (2);
}
}
for (i = 0; i < 15; i++)
{
for (j = 0; j < 15; j++)
{
if (a[i][j] == 1 && a[i + 1][j + 1] == 1 && a[i + 2][j + 2] == 1
&& a[i + 3][j + 3] == 1 && a[i + 4][j + 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i + 1][j + 1] == 2
&& a[i + 2][j + 2] == 2 && a[i + 3][j + 3] == 2
&& a[i + 4][j + 4] == 2)
return (2);
}
}
for (i = 4; i < 20; i++)
{
for (j = 4; j < 20; j++)
{
if (a[i][j] == 1 && a[i - 1][j - 1] == 1 && a[i - 2][j - 2] == 1
&& a[i - 3][j - 3] == 1 && a[i - 4][j - 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i - 1][j - 1] == 2
&& a[i - 2][j - 2] == 2 && a[i - 3][j - 3] == 2
&& a[i - 4][j - 4] == 2)
return (2);
}
}
return (0);
}
/************************ **************************** **********************/
void pingmu(void)
{
int i, j;
char *Msg[] = {
"Wan Jia1 an jian:", " shang:
" xia:
" zuo:
" you:
" fang zi: space", "", "Wan Jia2 an jian:", " shang:
" xia:
" zuo:
" you:
" fang zi: ENTER", "tui chu:", " ESC\n", NULL,
};
i = 0;
textcolor(RED);
while (Msg[i] != NULL)
{
gotoxy(25, 3 + i);
cputs(Msg[i]);
i++;
}
gotoxy(25, 20);
printf("\nqing wan jia %d chu ru:", wanjia);
gotoxy(jj + 1, ii + 1);
} /************************ **************************** ******************/
void guangbiaoyd(char an)
{
if (wanjia == 1)
{
switch (an)
{
case 'a':
jj--;
break;
case 'd':
jj++;
break;
case 'w':
ii--;
break;
case 's':
ii++;
break;
}
}
else
{
switch (an)
{
case 'j':
jj--;
break;
case 'l':
jj++;
break;
case 'i':
ii--;
break;
case 'k':
ii++;
break;
}
}
if (ii < 0)
ii++;
if (ii > 19)
ii--;
if (jj < 0)
jj++;
if (jj > 19)
jj--;
gotoxy(ii + 1, jj + 1);
} /************************ **************************** *******************/
void jh(int a[][20])
{
int k = 0;
if (wanjia == 1 && a[ii][jj] == 0 && k == 0)
{
a[ii][jj] = 1;
wanjia = 2;
k = 1;
}
else
{
if (a[ii][jj] ==0&& k == 0)
{
a[ii][jj] = 2;
wanjia = 1;
}
}
}
祝你愉快!
#include<stdio.h>
#include<dos.h> #include<conio.h> #include<ctype.h> #include<bios.h>
#define SHURU 1
#define FANGXIANG 2
#define WUXIAO 0
#define TUICHU 3
/************************ ****************************/
static int ii = 0, jj = 0, wanj ia = 1;
/************************ ****************************/
void hqp(int a[][20], int);
int anjian(char an);
int panduan(int a[][20]);
void pingmu(void);
void guangbiaoyd(char an)
void jh(int a[][20]);
/************************ ****************************/
void main()
{
int a[20][20] = { 0 }, tuichu = 0, ying;
char an;
hqp(a, 0);
pingmu();
while (1)
{
ying = panduan(a);
if (ying != 0)
hqp(a, ying);
an = getch();
switch (anjian(an))
{
case TUICHU:
clrscr();
tuichu = 1;
break;
case FANGXIANG:
guangbiaoy d(an);
break;
case SHURU:
switch (ying)
{
case 1:
hqp(a, 1);
tuichu = 1;
break;
case 2:
hqp(a, 2);
tuichu = 1;
break;
case 0:
jh(a);
break;
}
break;
case WUXIAO:
break;
}
hqp(a, 0);
pingmu();
if (tuichu == 1)
break;
}
} /************************ ****************************/
void hqp(int a[][20], int)
{
int i, j;
clrscr();
if (y != 0)
{
textcolor(RED);
printf("WAN JIA %d SHENG LI! ! ! ! ! \n", y);
}
for (i = 0; i < 20; i++)
{
for (j = 0; j < 20; j++)
{
switch (a[i][j])
{
case 1:
textcolor(YELLOW) putch('X');
break;
case 2:
textcolor(BLUE);
putch('0');
break;
case 0:
textcolor(GREEN);
if (j == 0)
{
if (i == 0)
{
putch(0xda);
break;
}
if (i == 19)
{
putch(0xc0);
break;
}
putch(0xc3);
break;
}
if (j == 19)
{
if (i == 0)
{
putch(0xbf);
break;
}
if (i == 19)
{
putch(0xd9);
break;
}
putch(0xb4);
break;
}
if (i == 0 && j != 0 && j != 19)
{
putch(0xc2);
break;
}
if (i == 19 && j != 0 && j != 19)
{
putch(0xc1);
break;
}
putch(0xc5);
break;
}
}
printf("\n");
}
} /************************ **************************** *************/
int anjian(char an)
{
if (an == 32 || an == 13)
return (SHURU);
else if (an == 'a' || an == 'w' || an == 's' || an == 'd' || an == 'j'
|| an == 'i' || an == 'k' || an == 'l')
return (FANGXIANG);
else if (an == 27)
return (TUICHU);
else
return (WUXIAO);
} /************************ **************************** **************/
int panduan(int a[][20])
{
int i, j;
for (i = 0; i < 20; i++)
{
for (j = 0; j < 15; j++)
{
if (a[i][j] == 1 && a[i][j + 1] = = 1 && a[i][j + 2] == 1
&& a[i][j + 3] = = 1 && a[i][j + 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i][j + 1] = = 2 && a[i][j + 2] == 2
&& a[i][j + 3] = = 2 && a[i][j + 4] == 2)
return (2);
}
}
for (i = 0; i < 15; i++)
{
for (j = 0; j < 20; j++)
{
if (a[i][j] == 1 && a[i + 1][j] = = 1 && a[i + 2][j] == 1
&& a[i + 3][j] = = 1 && a[i + 4][j] == 1)
return (1);
else if (a[i][j] == 2 && a[i + 1][j] = = 2 && a[i + 2][j] == 2
&& a[i + 3][j] = = 2 && a[i + 4][j] == 2)
return (2);
}
}
for (i = 0; i < 15; i++)
{
for (j = 0; j < 15; j++)
{
if (a[i][j] == 1 && a[i + 1][j + 1] == 1 && a[i + 2][j + 2] == 1
&& a[i + 3][j + 3] == 1 && a[i + 4][j + 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i + 1][j + 1] == 2
&& a[i + 2][j + 2] == 2 && a[i + 3][j + 3] == 2
&& a[i + 4][j + 4] == 2)
return (2);
}
}
for (i = 4; i < 20; i++)
{
for (j = 4; j < 20; j++)
{
if (a[i][j] == 1 && a[i - 1][j - 1] == 1 && a[i - 2][j - 2] == 1
&& a[i - 3][j - 3] == 1 && a[i - 4][j - 4] == 1)
return (1);
else if (a[i][j] == 2 && a[i - 1][j - 1] == 2
&& a[i - 2][j - 2] == 2 && a[i - 3][j - 3] == 2
&& a[i - 4][j - 4] == 2)
return (2);
}
}
return (0);
}
/************************ **************************** **********************/
void pingmu(void)
{
int i, j;
char *Msg[] = {
"Wan Jia1 an jian:", " shang:
" xia:
" zuo:
" you:
" fang zi: space", "", "Wan Jia2 an jian:", " shang:
" xia:
" zuo:
" you:
" fang zi: ENTER", "tui chu:", " ESC\n", NULL,
};
i = 0;
textcolor(RED);
while (Msg[i] != NULL)
{
gotoxy(25, 3 + i);
cputs(Msg[i]);
i++;
}
gotoxy(25, 20);
printf("\nqing wan jia %d chu ru:", wanjia);
gotoxy(jj + 1, ii + 1);
} /************************ **************************** ******************/
void guangbiaoyd(char an)
{
if (wanjia == 1)
{
switch (an)
{
case 'a':
jj--;
break;
case 'd':
jj++;
break;
case 'w':
ii--;
break;
case 's':
ii++;
break;
}
}
else
{
switch (an)
{
case 'j':
jj--;
break;
case 'l':
jj++;
break;
case 'i':
ii--;
break;
case 'k':
ii++;
break;
}
}
if (ii < 0)
ii++;
if (ii > 19)
ii--;
if (jj < 0)
jj++;
if (jj > 19)
jj--;
gotoxy(ii + 1, jj + 1);
} /************************ **************************** *******************/
void jh(int a[][20])
{
int k = 0;
if (wanjia == 1 && a[ii][jj] == 0 && k == 0)
{
a[ii][jj] = 1;
wanjia = 2;
k = 1;
}
else
{
if (a[ii][jj] ==0&& k == 0)
{
a[ii][jj] = 2;
wanjia = 1;
}
}
}
祝你愉快!
更多追问追答
追问
运行不了 bios.h 这个头文件我没有 网上搜了也没找到 请问你有么?
追答
你把你的邮箱给我吧,我发给你,太多了我发不了。我把它变成txt格式,发给你,可以不。我保存在了我的百度云,下载地址是
http://pan.baidu.com/share/link?shareid=3859292502&uk=203997823
去下载吧,是txt格式的文档。祝你愉快
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询