需要帮助C中的简单国际象棋程序 [英] Need help with the simple chess program in C

查看:56
本文介绍了需要帮助C中的简单国际象棋程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图从很多小时创建这个国际象棋程序,

仍然无法弄清楚如何完成它。在消耗了所有这些

的努力后,我第一次来到谷歌团体寻求帮助。如果有人帮助我调试程序

以下,我会很感激
。国际象棋棋盘假设用*打印。和空间 "作为

你可以在下面看到一个例子。再次感谢您的帮助

提前。


样本打印或输出:


*** ** ***** ***** *****

***** ***** ***** *****

***** ***** ***** *****

***** ***** ***** **** *

***** ***** ***** *****

***** ***** *** ** *****

#include< iostream>


使用命名空间std;


int main()

{

for(int row = 1; row< 9; row ++)//大排8次

{

for(int row1 = 1; row1< 4; row1 ++)//画一个小行3次

{

for(int col = 1; col< 9; col ++)//画一个大列8次

{

for(int col1 = 1; col1< 6; col1 ++) //画一个角色5



{

if(col%2 == 0&& row%2 == 0 )

{

cout<< ;'''';

}

其他

{

cout<< ''*'';

}

if(col1%2 == 0&& row1%2 == 0)

{

cout<<''';

}

else

{

cout<< ''*'';

}

}


}

}

}


返回0;

} //功能主

解决方案

as*****@hotmail.com 写道:


我一直试图从很多小时创建这个国际象棋程序,

仍然无法弄清楚如何完成它。在消耗了所有这些

的努力后,我第一次来到谷歌团体寻求帮助。



这不是Google群组。这是NNTP。 Google为NNTP新闻组提供了一个界面

以及Google网上论坛的界面。我认为他们实际上告诉你这不是谷歌小组。


这也是comp.lang.c,如果你没有问题与

相关的C语言尝试不同的组。所以,你提供的代码

应该是标准的ISO C.


i

如果有人帮助我会很感激出于此调试程序

以下。国际象棋棋盘假设用*打印。和空间 "作为

你可以在下面看到一个例子。再次感谢您的帮助

提前。


样本打印或输出:


*** ** ***** ***** *****

***** ***** ***** *****

***** ***** ***** *****

***** ***** ***** **** *

***** ***** ***** *****

***** ***** *** ** *****


#include< iostream>



这不是C中的标准标题。


>

使用namespace std;



这无法编译。


>

int main( )



int in(void)in C.


{

for(int row = 1; row< 9; row ++)//绘制大行8次



你不能在C中声明这样的行。是一些编译器

,这将允许你这样做作为扩展(gcc确实如此,我认为是b $ b)但它不是标准C.
< blockquote class =post_quotes>
{

for(int row1 = 1; row1< 4; row1 ++)//画一个小行3次

{

for(int col = 1; col< 9; col ++)//画一个大列8次

{

for( int col1 = 1; col1< 6; col1 ++)//画一个角色5



{

if(col%2 = = 0&& row%2 == 0)

{

cout<<''';

}

其他

{

cout << ''*'';

}

if(col1%2 == 0&& row1%2 == 0)

{

cout<<''';

}

else

{

cout<< ''*'';

}

}


}

}

}


返回0;

} //功能主



我我觉得每两行都有一个错误但是我会在我之前停下来让b $ b变得太烦人了:-)。你的代码不是C,它是C ++。对于C ++

代码尝试comp.lang.c ++,或者,如果你想在

C中解决这个问题,编写C代码并回到这里寻求帮助。 />

-

Ioan - Ciprian Tandau

tandau _at_ freeshell _dot_ org(希望现在还不晚)

(......它仍然有效......)


作为***** @ hotmail.com 写道:


我一直试图从很多小时创建这个国际象棋程序并且

仍然无法弄清楚如何完成它。在消耗了所有这些

的努力后,我第一次来到谷歌团体寻求帮助。如果有人帮助我调试程序

以下,我会很感激



< snip C ++代码>


这个组,你可以看到它的名字,处理C语言。

你的程序是用C ++编写的。 Ergo,发布到comp.lang.c ++或其他一些处理C ++的



11月16日星期四2006 22:54:42 -0500,Nelu< sp ******* @ gmail.comwrote
comp.lang.c中的

as*****@hotmail.com 写道:



[snip]


{

for(int row = 1; row< 9;行++)//画大行8次



你不能在C中声明这样的行。有一些编译器

那个会允许你这样做作为一个扩展(gcc确实如此,我认为是b $ b)但它不是标准的C.



其实它是。自1999年10月以来,已经超过7年

现在。


-

Jack Klein

主页: http://JK-Technology.Com


comp.lang.c的常见问题解答 http:// c- faq.com/

comp.lang.c ++ http://www.parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu。 edu /~a ... FAQ-acllc.html


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 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

解决方案

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 to this google groups for the first time for help.

This is not google groups. It''s NNTP. Google offers an interface
to NNTP newsgroups along with the interface to Google Groups. I
think they actually tell you that this is not Google Groups.

This is also comp.lang.c, if you don''t have questions related to
the C language try a different group. So, the code you provide
should be standard ISO C.

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>

This is not a standard header in C.

>
using namespace std;

This fails to compile.

>
int main()

int main(void) in C.

{
for (int row = 1; row < 9; row++)// Draw big row 8 times

You can''t declare row like this in C. There are some compilers
that would allow you to do this as an extension (gcc does, I
think) but it''s not standard C.

{
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

I think there''s a mistake every two lines but I''ll stop before I
get to be too annoying :-). Your code is not C, it''s C++. For C++
code try comp.lang.c++, or, if you want to solve that problem in
C, write C code and come back here for help.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it''s not too late)
(... and that it still works...)


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 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.

<snip C++ code>

This group, as you can see by it''s name, deals with the C language.
Your program is in C++. Ergo, post to comp.lang.c++ or some other group
that deals with C++.


On Thu, 16 Nov 2006 22:54:42 -0500, Nelu <sp*******@gmail.comwrote
in comp.lang.c:

as*****@hotmail.com wrote:

[snip]

{
for (int row = 1; row < 9; row++)// Draw big row 8 times


You can''t declare row like this in C. There are some compilers
that would allow you to do this as an extension (gcc does, I
think) but it''s not standard C.

Actually it is. And has been since October 1999, more than 7 years
now.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html


这篇关于需要帮助C中的简单国际象棋程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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