| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 805 人关注过本帖
标题:life 游戏问题
只看楼主 加入收藏
neillopv
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-8-31
收藏
 问题点数:0 回复次数:5 
life 游戏问题
/* Simulation of Conway's game of Lif on a bounded grid
Pre: The user must supply an initial configuration of living cells.
Post: The program prints a sequence of maps showing the changes in the configuration of living cells according to the rules for the game of Life.
Uses: functions Initialize,WriteMap,NeighborCount,and UserSaysYes */
#include"common.h" /* common include files and definitions */
#include"life.h" /* Life's defines,typedefs,and prototypes */
void main(void)
{
int row,col;
Grid map; /*current generation */
Grid newmap; /*next generation */
Initialize(map)
WriteMap(map);
printf("This is the initial configuration you have chosen.\n"
"Press<Enter>to continue.\n");
while(getchar()!='\n')
;
do{
for(row=1;row<=MAXROW;row++)
for(col=1;col<=MAXCOL;col++)
switch(NeighborCount(map,row,col)){
case 0:
case 1:
newmap[row][col]=DEAD;
break;
case 2:
newmap[row][col]=map[row][col]
break;
case 3:
newmap[row][col]=ALIVE;
break;
case 4:
case 5:
case 6:
case 7:
case 8:
newmap[row][col]=DEAD;
break;
}
CopyMap(map,newmap);
WriteMap(map);
printf("Do you wish to continue viewing the new generations");
}while(UserSaysYes());
}
问一下前面两行
#include"common.h" /* common include files and definitions */
#include"life.h" /* Life's defines,typedefs,and prototypes */
这个文件从哪来,怎么用上去?
搜索更多相关主题的帖子: life 游戏 
2007-10-22 22:43
子夜狂人
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-1-25
收藏
得分:0 

“引用头文件”这个说法楼主听说过吗?若果楼主知道引用头文件,还这样问的话,那应该是问得更深层的了。我想

我应该能理解楼主所问的问题,但是"common.h"和"life.h" 我没用过,更不用说回答你的问题了,呵呵,帮不上忙了。

这里说了这些,也只是希望往下来你这做客的朋友不会误会你的问题。还会关注

2007-10-22 23:20
C语言的深度
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:卡特的怀抱
等 级:版主
威 望:1
帖 子:9577
专家分:19
注 册:2007-10-22
收藏
得分:0 
``````额`厉害``我还不会`得学学下`

用代码打出楼房...用编程编出幸福...
2007-10-23 16:25
酒浪子
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-9-25
收藏
得分:0 

学习中!

2007-10-24 20:53
neillopv
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-8-31
收藏
得分:0 
common.h文件主要包括如下内容:
#include<stdio.h>
#include<stdib.h>
typedef enum Boolean{FALSE,TRUE}Boolean;
void Error(char*);
void Warning(char*);

life.h:
......
......
只是想知道如何使用这两个文件!!在主程开头写这些程序??
2007-10-24 20:59
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
收藏
得分:0 
生命游戏,我以前用VB做过,挺有趣的

头文件就是引用进来的,

#include"common.h" /* common include files and definitions */
#include"life.h" /* Life's defines,typedefs,and prototypes */

写了这两句,这两个文件的所有内容就自动加到了这个文件里面,可以直接调用这两个文件里面的函数

从BFS(Breadth First Study)到DFS(Depth First Study)
2007-10-24 21:21
快速回复:life 游戏问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011348 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved