"金刚石"问题 [英] "diamond" problem

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

问题描述

我是C ++的新手,并且对于

书中的一个问题有困难。

任何人都可以使用嵌套循环显示钻石形状

*。

*

***

*****

*******

*********

*******

*****

***

*

最小化printf函数调用次数。一个printf函数调用

只允许显示一个星。

i am a newber to C++ and have trouble with one of the problem from the
book.
can anyone able to use nested loops to display a diamond shape with "
* ".
*
***
*****
*******
*********
*******
*****
***
*
minimize the number of printf function calls. one printf function call
is allowed to display only one star.

推荐答案

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

i我是C ++的新手,并且对于

书中的一个问题有困难。

任何人都可以使用嵌套循环来显示带有
*"。

*

***

*****

*******

*********

*******

** ***

***

*

最小化printf函数调用的次数。一个printf函数调用

只允许显示一个星。
i am a newber to C++ and have trouble with one of the problem from the
book.
can anyone able to use nested loops to display a diamond shape with "
* ".
*
***
*****
*******
*********
*******
*****
***
*
minimize the number of printf function calls. one printf function call
is allowed to display only one star.



要获得代码帮助,请发布您编写的代码至今。如果你不了解任何有关能力的话,那就很难帮助你了。

看到你的一些代码是最简单的判断方法。


我相信你不会希望别人给你答案。如果你必须自己做一些工作,你可以学习更多



john

To get help on code, post the code you''ve written so far. It''s very
difficult to help without knowing anything about competent you are, and
seeing some of your code is the easiest way to judge that.

I sure you wouldn''t want someone to just give you the answer. You learn
more if you have to do some work yourself.

john



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

>

i是C ++的新手,并且对于

书中的一个问题有困难。任何人都可以使用嵌套循环来显示钻石形状
>
i am a newber to C++ and have trouble with one of the problem from the
book. can anyone able to use nested loops to display a diamond shape



让你在这里写下你编写的代码并且代码不起作用

你想要的。


-

Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new


在这个童话世界里卷是喜欢olso"

/ Gnume /

Let you write here code that you have written and the code do not work as
you want.

--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new

"In thi world of fairy tales rolls are liked olso"
/Gnume/


#include" stdio.h"

#include" math .h"

int main()

{

int line,space,stars,loop;


for(line = 1; line< = 5; line ++)

spaces = int abs(line-5);

for(loop = 1; loop< = spaces; loop ++)

printf("");

stars = line +(line-1);

for(loop = 1;循环< = stars;循环++)

printf(" *");

返回0;

}


我做了前5行并尝试了t o调试它但不起作用
#include "stdio.h"
#include "math.h"
int main()
{
int line,spaces,stars,loop;

for (line=1; line<=5; line++)
spaces=int abs(line-5);
for (loop=1; loop<=spaces; loop++)
printf(" ");
stars=line+(line-1);
for (loop=1; loop<=stars; loop++)
printf("*");
return 0;
}

I did the first 5 lines and try to debugg it but doesn''t work


这篇关于&QUOT;金刚石&QUOT;问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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