您能帮我注释下这个C语言程序!!!!!!!!急用,等着答辩!!!!!!谢谢啊!!!!!!!!!!!!!!!!由于字数,分成两个问题
elseif(k[i-4][j-20]!=1){gotoxy(j,i);cprintf("%d",k[i-4][j-20]);}textcolor(YELLOW);i=5...
else if(k[i-4][j-20]!=1)
{
gotoxy(j,i);
cprintf("%d",k[i-4][j-20]);
}
textcolor(YELLOW);
i=5;
j=21;
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
cprintf("7");
gotoxy(7,7);
cprintf("num:%d",num);
textcolor(WHITE);
gotoxy(11,22);
cprintf("Press any key to start game, Q key to quit...");
ch=getch();
if(ch=='Q'||ch=='q')
{
window(1,1,25,80);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
else
{
textcolor(YELLOW);
gotoxy(11,22);
cprintf(" ");
}
do
{
key=bioskey(0);
sound(200);
delay(1000);
nosound();
switch(key)
{
case DOWN:
{
if(k[i-4+1][j-20]==0)
continue;
if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
{
num+=k[i-4+1][j-20];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i++);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case UP:
{
if(k[i-4-1][j-20]==0)
continue;
if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
{
num+=k[i-4-1][j-20];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i--);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case LEFT:
{
if(k[i-4][j-20-1]==0)
continue;
if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
{
num+=k[i-4][j-20-1];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j--,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case RIGHT:
{
if(k[i-4][j-20+1]==0)
continue;
if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
{
num+=k[i-4][j-20+1];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j++,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
default:
continue;
}
}while(1);
} 展开
{
gotoxy(j,i);
cprintf("%d",k[i-4][j-20]);
}
textcolor(YELLOW);
i=5;
j=21;
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
cprintf("7");
gotoxy(7,7);
cprintf("num:%d",num);
textcolor(WHITE);
gotoxy(11,22);
cprintf("Press any key to start game, Q key to quit...");
ch=getch();
if(ch=='Q'||ch=='q')
{
window(1,1,25,80);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
else
{
textcolor(YELLOW);
gotoxy(11,22);
cprintf(" ");
}
do
{
key=bioskey(0);
sound(200);
delay(1000);
nosound();
switch(key)
{
case DOWN:
{
if(k[i-4+1][j-20]==0)
continue;
if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
{
num+=k[i-4+1][j-20];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i++);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case UP:
{
if(k[i-4-1][j-20]==0)
continue;
if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
{
num+=k[i-4-1][j-20];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i--);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case LEFT:
{
if(k[i-4][j-20-1]==0)
continue;
if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
{
num+=k[i-4][j-20-1];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j--,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
case RIGHT:
{
if(k[i-4][j-20+1]==0)
continue;
if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
{
num+=k[i-4][j-20+1];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j++,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);
goto aa;
}
break;
}
default:
continue;
}
}while(1);
} 展开
3个回答
展开全部
else if(k[i-4][j-20]!=1)/*将非1位置打印内容*/
{
gotoxy(j,i);
cprintf("%d",k[i-4][j-20]);
}
textcolor(YELLOW);/*设置当前字体为黄色*/
i=5;
j=21;
gotoxy(j,i);
cprintf("\1");/*21列第5列打印一个笑脸*/
gotoxy(33,5);/*33列第5行打印一个“7”*/
cprintf("7");
gotoxy(7,7);/*7行7列打印变量num值*/
cprintf("num:%d",num);
textcolor(WHITE);/*设置字体为白色*/
gotoxy(11,22);/*11列22行打印“任意键开始游戏,Q键退出*/
cprintf("Press any key to start game, Q key to quit...");
ch=getch();/*读取一个键盘输入*/
/*如果选择退出,则清屏,恢复黑白色,退出*/
if(ch=='Q'||ch=='q')
{
window(1,1,25,80);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
else
{/*否则将前景色置为黄色,11列22行的“开始游戏”提示清空*/
textcolor(YELLOW);
gotoxy(11,22);
cprintf(" ");
}
do
{/*读取键盘扫描码,用200HZ频率发1秒钟声音*/
key=bioskey(0);
sound(200);
delay(1000);
nosound();
/*上下左右光标移动*/
switch(key)
{
case DOWN:
{
if(k[i-4+1][j-20]==0)/*按“下”键到底则停止移动*/
continue;
/*否则数字往下移动*/
if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
{
num+=k[i-4+1][j-20];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i++);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);/*胜利条件*/
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{/*失败条件*/
lostgame(num);
goto aa;
}
break;
}
case UP:
{/*按“上”键到顶则停止移动*/
if(k[i-4-1][j-20]==0)
continue;
/*光标上移*/
if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
{
num+=k[i-4-1][j-20];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i--);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*胜利条件*/
else if(num!=7&&k[i-4][j-20]==7)
{/*失败条件*/
lostgame(num);
goto aa;
}
break;
}
case LEFT:
{/*按“左”键到边界则停止移动*/
if(k[i-4][j-20-1]==0)
continue;
/*光标左移*/
if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
{
num+=k[i-4][j-20-1];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j--,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*赢得比赛*/
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);/*玩家失败*/
goto aa;
}
break;
}
case RIGHT:
{/*按“右”键到边界则停止移动*/
if(k[i-4][j-20+1]==0)
continue;
if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
{/*光标右移*/
num+=k[i-4][j-20+1];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j++,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*赢得比赛*/
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);/*玩家失败*/
goto aa;
}
break;
}
default:
continue;
}
}while(1);
}
{
gotoxy(j,i);
cprintf("%d",k[i-4][j-20]);
}
textcolor(YELLOW);/*设置当前字体为黄色*/
i=5;
j=21;
gotoxy(j,i);
cprintf("\1");/*21列第5列打印一个笑脸*/
gotoxy(33,5);/*33列第5行打印一个“7”*/
cprintf("7");
gotoxy(7,7);/*7行7列打印变量num值*/
cprintf("num:%d",num);
textcolor(WHITE);/*设置字体为白色*/
gotoxy(11,22);/*11列22行打印“任意键开始游戏,Q键退出*/
cprintf("Press any key to start game, Q key to quit...");
ch=getch();/*读取一个键盘输入*/
/*如果选择退出,则清屏,恢复黑白色,退出*/
if(ch=='Q'||ch=='q')
{
window(1,1,25,80);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
else
{/*否则将前景色置为黄色,11列22行的“开始游戏”提示清空*/
textcolor(YELLOW);
gotoxy(11,22);
cprintf(" ");
}
do
{/*读取键盘扫描码,用200HZ频率发1秒钟声音*/
key=bioskey(0);
sound(200);
delay(1000);
nosound();
/*上下左右光标移动*/
switch(key)
{
case DOWN:
{
if(k[i-4+1][j-20]==0)/*按“下”键到底则停止移动*/
continue;
/*否则数字往下移动*/
if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
{
num+=k[i-4+1][j-20];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i++);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);/*胜利条件*/
if(k[i-4][j-20]==7&&num==7)
wingame();
else if(num!=7&&k[i-4][j-20]==7)
{/*失败条件*/
lostgame(num);
goto aa;
}
break;
}
case UP:
{/*按“上”键到顶则停止移动*/
if(k[i-4-1][j-20]==0)
continue;
/*光标上移*/
if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
{
num+=k[i-4-1][j-20];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j,i--);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*胜利条件*/
else if(num!=7&&k[i-4][j-20]==7)
{/*失败条件*/
lostgame(num);
goto aa;
}
break;
}
case LEFT:
{/*按“左”键到边界则停止移动*/
if(k[i-4][j-20-1]==0)
continue;
/*光标左移*/
if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
{
num+=k[i-4][j-20-1];
b[p++]=i+j-1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j--,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");
gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*赢得比赛*/
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);/*玩家失败*/
goto aa;
}
break;
}
case RIGHT:
{/*按“右”键到边界则停止移动*/
if(k[i-4][j-20+1]==0)
continue;
if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
{/*光标右移*/
num+=k[i-4][j-20+1];
b[p++]=i+j+1;
gotoxy(7,7);
cprintf("num:%d",num);
}
textcolor(YELLOW);
gotoxy(j++,i);
printf(" ");
gotoxy(j,i);
cprintf("\1");gotoxy(33,5);
if(k[i-4][j-20]==7&&num==7)
wingame();/*赢得比赛*/
else if(num!=7&&k[i-4][j-20]==7)
{
lostgame(num);/*玩家失败*/
goto aa;
}
break;
}
default:
continue;
}
}while(1);
}
展开全部
你这代码不完整,是个游戏的代码,里面的一些函数就是光标定位,设置文本颜色,设置文本背景颜色,定义游戏窗口,向当前窗口输出相应信息等等。
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
才5分 懒的看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询