[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
很多同学说C语言难学,不知道C语言学了能做什么,如果说不涉及嵌入式设备编程,我们可以用它来写游戏?是的,C语言能写的游戏有很多,推箱子,五子棋,等等
这里说一下,本人搞嵌入式编程的,主要是Linux平台,说起五子棋想必大家都不陌生,我的一个初中同学就是五子棋高手,几乎没人能下赢他,自号“十步一杀”,扯远了,今天这篇应该是我最后一篇C语言实现游戏系列了,期间收到许多朋友支持,在此我深表感谢,后面我主要会写一些讲算法的程序,毕竟算法是程序的灵魂嘛,希望大家一如既往的支持
还是那句话,程序=数据结构+算法,在写代码前,脑中先得有个基本建模,流程图,编码实现,最后调通。用最简明扼要的代码实现心中的功能就是好的程序员
废话不多说,上效果:
在20x20的棋盘上,找个小伙伴,我们来下一把五子棋,一方执黑子,一方执白子
通过轮流输入要放的棋子的位置坐标,来放置棋子
按照五子棋规则,谁先在一条直线上下够五个子,谁就赢棋
这个游戏是用C语言在windows下实现的,用到的大部分是标准库,没有平台依赖,源码只要稍作修改,就可以直接放到Linux下编译运行,源码获取方式请参考推箱子
不知觉间,用C语言写了一系列小游戏,回头看去,期间的付出历历在目,可编程就是这样,充满乐趣,好似在玩,让人乐此不疲,想起一句名言“做你喜欢的事,做你擅长的事”,每个人都可以成为好的程序员,
Just Do It!