能不能尽可能详细的帮我注释一下这个C语言程序呢?通过上下左右来移动光标的程序!!拜托啦, 我在TC下运行的.

#include<stdio.h>#include<bios.h>#include<conio.h>#defineESC0x011b#defineUP0x4800#def... #include <stdio.h>
#include <bios.h>
#include <conio.h>
#define ESC 0x011b
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00

typedef struct
{
int x;
int y;
}point;

DrawMan(int x, int y)
{
gotoxy(x, y);
printf("%c\b", 2);
}

DrawSpace(int x, int y)
{
gotoxy(x, y);
printf(" ");
}

int main()
{
point man = {35, 15};
int key = 0;
clrscr();
DrawMan(man.x, man.y);

while (key != ESC)
{
while (bioskey(1) == 0);
key = bioskey(0);

switch (key)
{
case UP:
DrawSpace(man.x, man.y);
--man.y;
DrawMan(man.x, man.y);
break;
case DOWN:
DrawSpace(man.x, man.y);
++man.y;
DrawMan(man.x, man.y);
break;
case LEFT:
DrawSpace(man.x, man.y);
--man.x;
DrawMan(man.x, man.y);
break;
case RIGHT:
DrawSpace(man.x, man.y);
++man.x;
DrawMan(man.x, man.y);
break;
defualt:
break;
}
}

return 0;
}
展开
 我来答
百度网友a671ecd3f
2010-10-27 · TA获得超过779个赞
知道小有建树答主
回答量:175
采纳率:0%
帮助的人:285万
展开全部
#include <stdio.h>
#include <bios.h>
#include <conio.h>
#define ESC 0x011b//这些是这几个键的键值
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00

typedef struct
{
int x;
int y;
}point;

DrawMan(int x, int y)
{
gotoxy(x, y);//移动到相应的位置
printf("%c\b", 2);//画笑脸
}

DrawSpace(int x, int y)
{
gotoxy(x, y);
printf(" ");
}

int main()
{
point man = {35, 15};
int key = 0;
clrscr();
DrawMan(man.x, man.y);

while (key != ESC)
{
while (bioskey(1) == 0);//bioskey(1)查询是否按下一个键,若按下一个键则返回键值,否则返回0。
key = bioskey(0);

switch (key)//筛选键值操作
{
case UP:
DrawSpace(man.x, man.y);
--man.y;//向上对应的坐标是y坐标减一,下面的类似就不再说了
DrawMan(man.x, man.y);
break;
case DOWN:
DrawSpace(man.x, man.y);
++man.y;
DrawMan(man.x, man.y);
break;
case LEFT:
DrawSpace(man.x, man.y);
--man.x;
DrawMan(man.x, man.y);
break;
case RIGHT:
DrawSpace(man.x, man.y);
++man.x;
DrawMan(man.x, man.y);
break;
defualt:
break;
}
}

return 0;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式