How to display chessboard using while | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to display chessboard using while

i have try many time, but it still not correct U_U anyone help please. They want us to display the chessboard with the given cell from user. Ex: user input 3 cell. display: ***___***___***___ ***___***___***___ ***___***___***___ ___***___***___*** ___***___***___*** ___***___***___*** The line is always 6 and the column is always 4 just that the amout of * or _ to display is input by user

28th Dec 2016, 2:17 AM
Otaku Tenjito
Otaku Tenjito - avatar
14 Answers
+ 1
they want the user to imput the cell Ex: cin>>4 the cell change to ****____ cin>>6 the cell change to ******______ By what i mean is that the amout of * or _ is imput by user, but for only 1 time. @ Vishal
28th Dec 2016, 2:57 AM
Otaku Tenjito
Otaku Tenjito - avatar
+ 1
#include <iostream> //to make string output #include <string> using namespace std; int main() {     string black;     string white;     int cells;     int boardSize = 0; //starting number     cout << "How many cells?: ";     cin >> cells;     //add to black and white the number of cells     for (int x = 0; x < cells; ++x) {         black += "*";         white += "_";     }     //6 for 6 lines     while (boardSize < 6) {         //3 for black and white 3 times         for (int i = 0; i < 3; ++i) {             cout << black << white;         }         cout << endl;         ++boardSize;     } }
28th Dec 2016, 4:51 AM
Vishal++
Vishal++ - avatar
+ 1
Convert that for to while. This is something u must do
28th Dec 2016, 8:06 AM
Vishal++
Vishal++ - avatar
+ 1
If you really mean the word in ur name "Otaku". You must really learn coding to every last bit!
28th Dec 2016, 8:08 AM
Vishal++
Vishal++ - avatar
+ 1
xD i dun know if i should say thank you or kill you instead😂 Thank u hahahha i will try
28th Dec 2016, 8:43 AM
Otaku Tenjito
Otaku Tenjito - avatar
0
i use in c++ for my homework
28th Dec 2016, 2:26 AM
Otaku Tenjito
Otaku Tenjito - avatar
0
cool, i am planning on using c# in a game engine, its my 1st attempt.
28th Dec 2016, 2:31 AM
Gavin Streete
Gavin Streete - avatar
0
x'D i'm just a beginner, my classmate are all boys and they catch up easily and they try hard, while i study 3 majors and dun do any excersices, just that i start to try hard from now on, ;_; but i dun have much time since i am always study and tired af
28th Dec 2016, 2:33 AM
Otaku Tenjito
Otaku Tenjito - avatar
0
@Otaku You want to display a chessboard on the screen with *** as black and ___ as white? If yes, what do u mean be user inputs 3?
28th Dec 2016, 2:54 AM
Vishal++
Vishal++ - avatar
0
Understood. And its 6x6 chessboard instead of original 8x8 chessboard. Otaku, how about u start writing the program? And when ur stuck I can help
28th Dec 2016, 4:09 AM
Vishal++
Vishal++ - avatar
0
😂 ok, but i didn't display anythings that is why i wonder wth is wrong with it i will write it to u, but i have 4 class this afternoon, so i can't write it now ad thank q so much
28th Dec 2016, 4:13 AM
Otaku Tenjito
Otaku Tenjito - avatar
0
Thank you so much!! but i haven't write the code yet. I will test it tonight!!! * bow* really thank you.
28th Dec 2016, 6:09 AM
Otaku Tenjito
Otaku Tenjito - avatar
0
;_; but he said to only use while or do not for
28th Dec 2016, 7:47 AM
Otaku Tenjito
Otaku Tenjito - avatar
- 1
how is c++? i have never tried it before. you using an game engine or Microsoft visual?
28th Dec 2016, 2:21 AM
Gavin Streete
Gavin Streete - avatar