战舰计划 [英] Battleship program

查看:106
本文介绍了战舰计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我即将创建一个8x8战列舰计划。

总共应该有8艘船,尺寸为1x1。

但是,我不知道如何随机放置船只。

以下是我在做一些研究后开始的一些代码

展开 | 选择 | 换行 | 行号

解决方案

查看rand和srand函数:
LINK
LINK






我是ab出去创建8x8战列舰计划。

总共应该有8艘船,尺寸为1x1。

但是,我不知道如何随机放置船只。

以下是我在做一些研究后开始的一些代码

展开 | 选择 | 换行 | 行号


< blockquote>好的,想一想。您需要打印16列和8行(中间有一些空格)。您如何认为必须调整for循环才能实现您的需求?


Hi,

I was about to create a 8x8 battleship program.
there should be 8 ships in total with 1x1 size.
However, I do not know how to place the ships randomly.
Below are some of the codes that I started after doing some research

Expand|Select|Wrap|Line Numbers

解决方案

Check out the rand and srand functions:
LINK
LINK


Hi,

I was about to create a 8x8 battleship program.
there should be 8 ships in total with 1x1 size.
However, I do not know how to place the ships randomly.
Below are some of the codes that I started after doing some research

Expand|Select|Wrap|Line Numbers


Ok, think about that. You need to print 16 columns and 8 rows (with some space in between). How do you think you have to adjust your for loops do achieve what you need?


这篇关于战舰计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆