#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<windows.h>
main()
{
int a[100],b[100],c,d,e[2]={10,0},f=0,g[2],i=0;
char h[2]={d};
a[0]=50;
a[1]=60;
a[2]=70;
a[3]=80;
b[0]=20;
b[1]=20;
b[2]=20;
b[3]=20;
c=3;
initgraph(500,500);
while(1)
{
if(f==0)
{
g[0]=10*(rand()%50);
g[1]=10*(rand()%50);
f=1;
}
fillrectangle(g[0],g[1],g[0]+5,g[1]+5);
if(kbhit())
{
h[1]=h[0];
h[0]=getch();
}
rectangle(0,0,500,500);
if(h[0]=='A'&&h[1]!='D')
{
e[0]=-10;
e[1]=0;
}
if(h[0]=='S'&&h[1]!='W')
{
e[0]=0;
e[1]=10;
}
if(h[0]=='D'&&h[1]!='A')
{
e[0]=10;
e[1]=0;
}
if(h[0]=='W'&&h[1]!='S')
{
e[0]=0;
e[1]=-10;
}
for(d=0;d<c;d++)
{
a[d]=a[d+1];
b[d]=b[d+1];
}
if(a[c]+e[0]!=g[0]||b[c]+e[1]!=g[1])
{
a[c]+=e[0];
b[c]+=e[1];
}
if(a[c]+e[0]==g[0]&&b[c]+e[1]==g[1])
{
a[c+1]=g[0];
b[c+1]=g[1];
f=0;
c++;
}
if(a[c]==510||b[c]==510||a[c]==-10||b[c]==-10)
break;
for(d=0;d<c;d++)
{
if(a[c]==a[d]&&b[c]==b[d])
{
i=1;
break;
}
}
if(i==1)
break;
for(d=0;d<=c;d++)
{
fillrectangle(a[d],b[d],a[d]+5,b[d]+5);
}
Sleep(100);
cleardevice();
continue;
}
printf("生活如此艰难\n你长到了%d米",c+1);
}
已经换了输入法,在运行中移动键asdw总是变成中文拼音格式,程序结束之后又可以改回来,求解决方法?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- threenewbee 2019-09-22 18:58关注
和你的输入法冲突,百度这种山寨的输入法软件存在很多问题,在运行的时候切换到英文输入法状态,或者卸载百度输入法,使用默认的微软拼音就可以了。
解决 无用评论 打赏 举报
悬赏问题
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥200 uniapp长期运行卡死问题解决
- ¥15 latex怎么处理论文引理引用参考文献
- ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
- ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
- ¥15 乘性高斯噪声在深度学习网络中的应用