海龟图
来源:互联网 发布:天狼50软件怎么样 编辑:程序博客网 时间:2024/05/04 12:19
#include <stdio.h>
void move();
void print();
int floor[20][20]={0};
int px=0,py=0,pen=0,detection=0;
int main()
{
int input;
printf("please input number:");
scanf("%d",&input);
while(input!=9)
{switch(input)
{
case 1 :
pen=0;break;
case 2 :
pen=1;break;
case 3 :
detection=(detection+1)%4;break;
case 4 :
detection=(detection+3)%4;break;
case 5 :
move();break;
case 6 :
print();break;
case 9 :
break;
default :
printf("error");
break;
}
printf("pleasr input number again:");
scanf("%d",&input);
}
return 0;
}
void print()
{
int i,j;
for(i=0;i<20;i++)
{
for(j=0;j<20;j++)
{
if(px==i&&py==j)
printf("#");
else
{ if(floor[i][j]==0)
printf(" ");
if(floor[i][j]==1)
printf("*");
}
}
printf("\n");
}
}
void move()
{
int i,n;
printf("please inpur N:\n");
scanf("%d",&n);
if(detection==0)
{
for(i=0;i<n&&py<19;i++)
{ py++;
if(pen==1)
floor[px][py-1]=1;
}
}
else if(1==detection)
{
for(i=0;i<n&&px<19;i++)
{ px++;
if(pen==1)
floor[px-1][py]=1;
}
}
else if(2==detection)
{
for(i=0;i<n&&py>0;i++)
{ py--;
if(pen==1)
floor[px][py+1]=1;
}
}
else if(3==detection)
{
for(i=0;i<n&&px>0;i++)
{ px--;
if(pen==1)
floor[px+1][py]=1;
}
}
}
- 海龟图
- 海龟图 问题
- 海龟作图源程序
- 海龟出炉了~~
- 天南地北海龟一派
- 海龟交易法则
- ”海龟“找工作难不难?
- 我来看海龟
- python海龟绘图实例教程
- Python 海龟绘图
- 海龟交易系统R代码
- Python海龟画棋盘
- python海龟绘图实例教程
- 海龟git操作教程
- 海龟绘图--画直方图
- 海龟绘图-字符串
- 【量化课堂】海龟策略
- 经典海龟交易法
- 设计模式之十一:创建模式(Builder Pattern)
- 【python】-lambda
- java中类成员如果没有修饰符其访问权限
- 音视频同步-时间戳
- Android应用开发--MP3音乐播放器界面设计(1)
- 海龟图
- 【综述】(MIT博士)林达华老师-"概率模型与计算机视觉”
- ubuntu12.04 .bashrc设置后无效
- 【python】-list,tuple,dict
- UIViewController的生命周期
- 上拉电阻
- 极客技术专题【004期】:Web开发人员的必备工具 - Emmet (Zen Coding)基本使用
- hdu2795 Billboard(单点更新)
- 在MFC中从一个线程工作函数中向窗口发送消息(this指针的妙用)