本节包含一些我为了娱乐而编写的程序。这些程序并非最佳编程实践,也不是 ncurses 的最佳使用方法。提供这些程序旨在帮助初学者获得启发,并鼓励他们向本节贡献更多程序。如果您编写了一些不错的、简单的 curses 程序,并希望将它们收录在此处,请联系 我。
生命游戏是数学的奇迹。正如 Paul Callahan 所说
The Game of Life (or simply Life) is not a game in the conventional sense. There are no players, and no winning or losing. Once the "pieces" are placed in the starting position, the rules determine everything that happens later. Nevertheless, Life is full of surprises! In most cases, it is impossible to look at a starting position (or pattern) and see what will happen in the future. The only way to find out is to follow the rules of the game. |
这个程序从一个简单的倒 U 形图案开始,展示了生命游戏的奇妙之处。这个程序还有很大的改进空间。您可以让用户输入他们选择的图案,甚至从文件中读取输入。您还可以更改规则,并尝试各种变体。在 谷歌 上搜索有关生命游戏的有趣信息。
文件路径: JustForFun/life.c
幻方,又一个数学奇迹,理解起来很简单,但制作起来却非常困难。在幻方中,每行、每列的数字之和都相等。甚至对角线之和也可以相等。幻方有很多具有特殊性质的变体。
这个程序创建了一个简单的奇数阶幻方。
文件路径: JustForFun/magic.c
著名的汉诺塔问题求解程序。游戏的目标是将第一个柱子上的圆盘移动到最后一个柱子上,使用中间的柱子作为临时存放处。规则是任何时候都不能将较大的圆盘放在较小的圆盘上面。
文件路径: JustForFun/hanoi.c