三九宝宝网宝宝教育教学论文

用C语言编写迷宫问题

12月22日 编辑 39baobao.com

[迷宫大发现]活动名称:益智活动《迷宫大发现》 活动目标:1.参照自己设计的迷宫图,搭建迷宫,在游戏中发现问题,修改完善设计图,增加游戏趣味性。 2.鼓励幼儿大胆表达,操作,交流,感受合作游戏的快乐...+阅读

1995年第十二届IOCCC获奖作品,由葡萄牙的Carlos Duarte先生所编写。评委们评论说:

This could be used as the basis of an a-maze-ing screen exerciser.

以下是作者本人对程序的简要介绍:

A program that generates a maze, and then solves it, all this being seen by the user. Some highlights of obfuscation are: 3 steps functions in one - main(), several recursive calls with conditional actions, and just one (big and ugly) statement to solve the maze.

你可以从.ioccc.org上找到这个名为cdua.c的源程序,也可以参考下面的代码。由于这里上传的代码会被重新格式化,强烈建议你去下载原来的程序。

/*************************************************************/

#define r return

char*u0=" to begin... ",*u1="Already been here!",*u2="Found a wall! \

",*u3="Walking... ",*u4="Finished. ",*u5="Going back..\

. ",*o="\033[23;1HDone!!\n",*x="\033[2J",*y="\033[1;1H",*z="\033[%d;%\

dH%c",*w="\033[1;1H%s",*v="\033[%d;%dH%c\033[%d;%dH%c\033[%d;%dH%c",b[1841

];int c,d,e,f,g;typedef int(*h)();h i,j,k,l,m,n;int printf(),srand(),rand(

),time(),getchar();int main(int a){i=printf,j=srand,k=rand,l=time,m=getchar,

n=main;if(!c)for(j(l(0)),g=a=1000,--d;++d<1840;b[c=d]=" #\n"[d%80==79?2:d/80

&d%80&d/80-22&d%80-78]);if(!(c-1839))++c,i("%s%s%s",x,y,b);k:if(!(c-1840)

&(b[a+2]+b[a-2]+b[a+160]+b[a-160]-4*' ')){while(b[a+(f=(e=k()%4)?e-1?e-2?-1

:1:-80:80)*2]!='#');b[a]=b[a+f]=b[f+a+f]=' ';i(v,a/80+1,1+a%80,' ',(a+f)/80+

1,1+(a+f)%80,' ',(f+a+f)/80+1,1+(f+a+f)%80,' ');n(f+a+f);goto k;}else if(!(g

-a))c=1,a=162,i(w,u0),m();if(c-1){}else r b[a]!=' '?(i(w,b[a]=='.'?u1:u2),0)

:(b[a]='.',i(w,u3),i(z,a/80+1,1+a%80,'.'),a==1676?(i(w,u4),i(o),1):n(a+1)||n

(a+80)||n(a-80)||n(a-1)?1:(b[a]=' ',i(w,u5),i(z,a/80+1,1+a%80,' '),0));r 0;}

我曾运行过这个程序,非常的有意思,当然,尝试理解这样的代码更有趣。

以下为关联文档:

C语言问题编写赋值函数#include #include int assignment(int *,int); void print(int *,int); void main() { int sz,rt; int *p; //定义一个指针,在子函数里再动态分配内存 printf("输入data的数据...

用VHDL语言编写程序:可逆的60进制计数器library ieee; use ieee.std_logic_1164.all; entity decode3_8 is port ( din : in std_logic_vector (2 downto 0); en : in std_logic; xout : out std_logic_vector (7...

用C语言编一个迷宫程序-# --------### # ## # # ### ----# # #-## # # # #### #### # ## ## #-# ## # # # #---# ## # ## # # # # -# ### ## #### ## # # ----# # # ## # # # ## ### ## -# --# --...

c语言迷宫问题问题出在MazePath内部的e是一个局部变量,并且随着while循环其内容不断变化。保存一个局部变量的地址是没有意义的,函数返回后就被清除。解决的办法是动态分配QElemType类型的...

推荐阅读
图文推荐