使用While语句的Chess Board Program [英] Chess Board Program using While statements

查看:131
本文介绍了使用While语句的Chess Board Program的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用while语句创建棋盘程序,你只能使用两个cout语句..(使用C ++)

一个cout是cout<< whiteRow<< endl;

其他cout是cout<< blackRow<< endl;


whiteRow = WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK;


blackRow = BLACK + WHITE +黑色+白色+黑色+白色+黑色+白色;


该程序的尺寸为8个5行,看起来相似?

远这就是我所拥有的:


#include< iostream>

#include< string>

using namespace std;


const string BLACK =" ********";

const string WHITE =" ;


int main()

{


whiteRow = WHITE + BLACK + WHITE + BLACK +白色+黑色+白色+黑色;


blackRow =黑色+白色+黑色+白色+黑色+白色+黑色+白色;


while(count< = 5)

cout<< whiteRow<< endl;

count ++

innercount = 0

while(innercount< 5)

cout< < blackRow<< endl;

innercount ++



~~~可以真的使用帮助谢谢你


请帮助..

Create a chessboard program by using while statements and you can only use TWO cout statments.. (using C++)
One cout is cout<< whiteRow << endl;
THe other cout is cout <<blackRow << endl;

whiteRow = WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK;

blackRow = BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE;

The program has the dimensions of 8 blocks of 5 lines that look alike ??
SO far this is what I have:

#include <iostream>
#include <string>
using namespace std;

const string BLACK = "********";
const string WHITE = " ";

int main ()
{

whiteRow = WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK;

blackRow = BLACK + WHITE + BLACK + WHITE + BLACK + WHITE + BLACK + WHITE;

while (count <= 5)
cout << whiteRow << endl;
count ++
innercount = 0
while (innercount <5)
cout << blackRow << endl;
innercount++



~~~ Could really use the help THANKYOU

Please Help..

推荐答案

请阅读我们的发布指南。你还没有真正让我们知道你遇到了什么问题,你没有使用[code]标签,而且你发错了。在再次发布之前,请务必阅读并理解上述指南。谢谢。
Please read our Posting Guidelines. You haven''t really given us an idea of what you''re having trouble with, you didn''t use [code] tags, and you posted in the wrong section. Please make sure you read and understand the above guidelines before posting again. Thank you.


展开 | 选择 | Wrap | 行号


重新发布时,向我们展示棋盘的一些输出。


几个问题。为什么算= = 5?我认为棋盘有8排。


你的白色字符串是空的。当你将白色与黑色相结合时,你只能看到黑色。如果您所做的只是打印字符串,我可以看到这是通过一个while循环完成的。
When you repost, show us some output of the chessboard.

A couple of questions. Why count == 5? I thought chess boards had 8 rows.

Your white string is null. When you concate white with black, you''ll only see black. If all you are doing is printing out strings, I can see this being done with a single while loop.


这篇关于使用While语句的Chess Board Program的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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