I have been trying to create this chess program from many hours and
still couldn't figure out how to complete it. After consume all these
efforts i come here for the first time for help. i
would appreciate if somebody help me out of this to debug the program
below. The chess board suppose to be printed with "*" and space " " as
you can see below as an example. Again I would appreciate for your help
in advance.
sample print or output:
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
#include <iostream>
using namespace std;
int main()
{
for (int row = 1; row < 9; row++)// Draw big row 8 times
{
for (int row1 = 1; row1 < 4; row1++) //Draw a little row 3 times
{
for (int col = 1; col < 9; col++) //Draw a big column 8 times
{
for (int col1 = 1; col1 < 6; col1++) //Draw a character 5
times
{
if (col % 2 == 0 && row % 2 == 0)
{
cout <<' ';
}
else
{
cout << '*';
}
if(col1%2 == 0 && row1 % 2 ==0)
{
cout <<' ';
}
else
{
cout << '*';
}
}
}
}
}
return 0;
} // function main 6 3106 as*****@hotmail .com wrote:
I have been trying to create this chess program from many hours and
still couldn't figure out how to complete it. After consume all these
efforts i come here for the first time for help. i
would appreciate if somebody help me out of this to debug the program
below. The chess board suppose to be printed with "*" and space " " as
you can see below as an example. Again I would appreciate for your help
in advance.
sample print or output:
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
I didn't actually run your code but just from glancing at it there's a
glaring problem. You never output any line breaks! Try to find the
appropriate place to insert those.
>
#include <iostream>
using namespace std;
int main()
{
for (int row = 1; row < 9; row++)// Draw big row 8 times
{
for (int row1 = 1; row1 < 4; row1++) //Draw a little row 3 times
{
for (int col = 1; col < 9; col++) //Draw a big column 8 times
{
for (int col1 = 1; col1 < 6; col1++) //Draw a character 5
times
{
if (col % 2 == 0 && row % 2 == 0)
{
cout <<' ';
}
else
{
cout << '*';
}
if(col1%2 == 0 && row1 % 2 ==0)
{
cout <<' ';
}
else
{
cout << '*';
}
}
}
}
}
return 0;
} // function main
<as*****@hotmai l.comwrote in message
news:11******** *************@f 16g2000cwb.goog legroups.com...
>I have been trying to create this chess program from many hours and
still couldn't figure out how to complete it. After consume all these
efforts i come here for the first time for help. i
would appreciate if somebody help me out of this to debug the program
below. The chess board suppose to be printed with "*" and space " " as
you can see below as an example. Again I would appreciate for your help
in advance.
sample print or output:
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
***** ***** ***** *****
#include <iostream>
using namespace std;
int main()
{
for (int row = 1; row < 9; row++)// Draw big row 8 times
{
for (int row1 = 1; row1 < 4; row1++) //Draw a little row 3 times
{
for (int col = 1; col < 9; col++) //Draw a big column 8 times
{
for (int col1 = 1; col1 < 6; col1++) //Draw a character 5
times
{
if (col % 2 == 0 && row % 2 == 0)
{
cout <<' ';
}
else
{
cout << '*';
}
if(col1%2 == 0 && row1 % 2 ==0)
{
cout <<' ';
}
else
{
cout << '*';
}
}
}
}
}
return 0;
} // function main
Consider breaking it down into simpler steps.
#include <iostream>
#include <string>
void OutputChar( char ThisChar, size_t times )
{
for ( size_t i = 0; i < times; ++i )
std::cout << ThisChar;
}
void OutputLine1()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( '*', 5 );
OutputChar( ' ', 5 );
}
std::cout << "\n";
}
void OutputLine2()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( ' ', 5 );
OutputChar( '*', 5 );
}
std::cout << "\n";
}
void OutputBoard()
{
for ( int i = 0; i < 4; ++i )
{
for ( int j = 0; j < 5; ++j )
OutputLine1();
for ( int j = 0; j < 5; ++j )
OutputLine2();
}
}
int main()
{
OutputBoard();
std::string wait;
std::getline( std::cin, wait );
return 0;
}
Jim Langston wrote:
>
Consider breaking it down into simpler steps.
#include <iostream>
#include <string>
void OutputChar( char ThisChar, size_t times )
{
for ( size_t i = 0; i < times; ++i )
std::cout << ThisChar;
}
void OutputLine1()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( '*', 5 );
OutputChar( ' ', 5 );
}
std::cout << "\n";
}
void OutputLine2()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( ' ', 5 );
OutputChar( '*', 5 );
}
std::cout << "\n";
}
void OutputBoard()
{
for ( int i = 0; i < 4; ++i )
{
for ( int j = 0; j < 5; ++j )
OutputLine1();
for ( int j = 0; j < 5; ++j )
OutputLine2();
}
}
int main()
{
OutputBoard();
std::string wait;
std::getline( std::cin, wait );
return 0;
}
Or simply
#include <iostream>
int main() {
for(int i = 0; i < 3*8; ++i) {
for(int j = 0; j < 5*8; ++j)
std::cout << ((i/3)%2 == (j/5)%2 ? '*' : ' ');
std::cout << '\n';
}
}
Thanks guys for the help. i am glad to tell you that i figure out the
progam myself. I worte it below.I tried your program its not compiling
and for more info i am using putty for connecting and compiling.
#include <iostream>
using namespace std;
int main()
{
cout << endl;
for ( int mm = 1; mm < 5; mm++ )
{
for ( int row = 0; row < 3; row++ )
{
for ( int column = 0; column < 4; column++ )
{
for ( int i = 1; i < 6; i++ )
cout << "*";
for ( int j = 1; j < 6; j++)
cout << " ";
} // for column
cout << endl;
} // for row
for ( int row2 = 0; row2 < 3; row2++ )
{
for ( int column2 = 0; column2 < 4; column2++ )
{
for (int i2 = 1; i2 < 6; i2++)
cout << " ";
for ( int j2 = 1; j2 < 6; j2++ )
cout<< "*";
} // for column2
cout << endl;
} // for row2
} // for mm
return 0;
} // function main
n.torrey.pines wrote:
Jim Langston wrote:
Consider breaking it down into simpler steps.
#include <iostream>
#include <string>
void OutputChar( char ThisChar, size_t times )
{
for ( size_t i = 0; i < times; ++i )
std::cout << ThisChar;
}
void OutputLine1()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( '*', 5 );
OutputChar( ' ', 5 );
}
std::cout << "\n";
}
void OutputLine2()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( ' ', 5 );
OutputChar( '*', 5 );
}
std::cout << "\n";
}
void OutputBoard()
{
for ( int i = 0; i < 4; ++i )
{
for ( int j = 0; j < 5; ++j )
OutputLine1();
for ( int j = 0; j < 5; ++j )
OutputLine2();
}
}
int main()
{
OutputBoard();
std::string wait;
std::getline( std::cin, wait );
return 0;
}
Or simply
#include <iostream>
int main() {
for(int i = 0; i < 3*8; ++i) {
for(int j = 0; j < 5*8; ++j)
std::cout << ((i/3)%2 == (j/5)%2 ? '*' : ' ');
std::cout << '\n';
}
}
I have another program to write, i will appreciate if somebody can
help......promp ts the user to enter positive integer, and then prints
out four triangles
For Example: If we enter 4 it shouls shows
*
* *
* * *
* * * *
* * * *
* * *
* *
*
* * * *
* * *
* *
*
*
* *
* * *
* * * *
Thanks again.
asif...@hotmail .com wrote:
Thanks guys for the help. i am glad to tell you that i figure out the
progam myself. I worte it below.I tried your program its not compiling
and for more info i am using putty for connecting and compiling.
#include <iostream>
using namespace std;
int main()
{
cout << endl;
for ( int mm = 1; mm < 5; mm++ )
{
for ( int row = 0; row < 3; row++ )
{
for ( int column = 0; column < 4; column++ )
{
for ( int i = 1; i < 6; i++ )
cout << "*";
for ( int j = 1; j < 6; j++)
cout << " ";
} // for column
cout << endl;
} // for row
for ( int row2 = 0; row2 < 3; row2++ )
{
for ( int column2 = 0; column2 < 4; column2++ )
{
for (int i2 = 1; i2 < 6; i2++)
cout << " ";
for ( int j2 = 1; j2 < 6; j2++ )
cout<< "*";
} // for column2
cout << endl;
} // for row2
} // for mm
return 0;
} // function main
n.torrey.pines wrote:
Jim Langston wrote:
>
Consider breaking it down into simpler steps.
>
#include <iostream>
#include <string>
>
void OutputChar( char ThisChar, size_t times )
{
for ( size_t i = 0; i < times; ++i )
std::cout << ThisChar;
}
>
void OutputLine1()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( '*', 5 );
OutputChar( ' ', 5 );
}
std::cout << "\n";
}
>
void OutputLine2()
{
for ( int i = 0; i < 4; ++i )
{
OutputChar( ' ', 5 );
OutputChar( '*', 5 );
}
std::cout << "\n";
}
>
void OutputBoard()
{
for ( int i = 0; i < 4; ++i )
{
for ( int j = 0; j < 5; ++j )
OutputLine1();
for ( int j = 0; j < 5; ++j )
OutputLine2();
}
}
>
int main()
{
>
OutputBoard();
>
std::string wait;
std::getline( std::cin, wait );
return 0;
}
>
>
Or simply
#include <iostream>
int main() {
for(int i = 0; i < 3*8; ++i) {
for(int j = 0; j < 5*8; ++j)
std::cout << ((i/3)%2 == (j/5)%2 ? '*' : ' ');
std::cout << '\n';
}
}
* as*****@hotmail .com:
I have another program to write, i will appreciate if somebody can
help......promp ts the user to enter positive integer, and then prints
out four triangles
For Example: If we enter 4 it shouls shows
*
* *
* * *
* * * *
* * * *
* * *
* *
*
* * * *
* * *
* *
*
*
* *
* * *
* * * *
See the FAQ for reasons why you should (1) stop TOP-POSTING, and (2)
stop asking for solutions to HOMEWORK.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: derian |
last post by:
Do you guys know if there is a program that can generate chess moves? I
recently wrote a chess game but its only 2 player... I deceided it
was too difficult to come up with the logic for the AI movements... anyone
know where i can find a DLL that will generate chess moves? Ideally, the
DLL would accept moves made by the human player and generate an AI move
based on that. Any help would be much appreciated
:\\ME
|
by: asif929 |
last post by:
I have been trying to create this chess program from many hours and
still couldn't figure out how to complete it. After consume all these
efforts i come to this google groups for the first time for help. i
would appreciate if somebody help me out of this to debug the program
below. The chess board suppose to be printed with "*" and space " " as
you can see below as an example. Again I would appreciate for your help
in advance.
sample...
|
by: biyubi |
last post by:
Hi, a year ago I won the 2005 Best Game categoryof the International
Obfuscated C Code Contestwith a chess program.
http://www.ioccc.org/whowon2005.html
http://www.mailcom.com/ioccc/toledo/hint.htmBut this post is because I
have discovered (asurprise for me) that it is also the worldsmallest
chess program written in C language.It has a size of 3004 bytes, or
2261 bytes simplydeleting all the spacing that makes the knightfigure,
cutting...
|
by: sam_cit |
last post by:
Hi Everyone,
I'm working on developing a chess game and i decided to use c++ for
its object oriented approach. I have a bass class unit and is
inherited to distinct number of units (like king, queen, pawns
etc...), i will have pure virtual functions in the base class for
move(), attack() etc which are applicable to all units and would
override them in the child classes. Function specific to pawn like
recovering of another unit once it...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |