for循环创建四个直角三角形直方图......帮助!! [英] For loops to create four right triangle histograms...HELP!!

查看:66
本文介绍了for循环创建四个直角三角形直方图......帮助!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,

这是我的第一篇文章。我真的希望那里有人解决我的C ++编码问题...


这是我的代码和我必须要做的...

我认为它是1到10行然后回来


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


//这些直方图应该像这样打印在彼此旁边:

// * ******************** *

// ** ********* ********* **

// *** ******** ******** ***

// **** ******* ******* ****

// ***** ****** **** ** *****

// ****** ***** ***** ******

// * ****** **** **** *******

// ******** *** *** ***** ***

// ********* ** ** *********

// ***** ***** ***********

//但是我不能让它们在每个人旁边疗法。我的下面的代码中有两个,

//但是它们是另一个!不是我需要的......


//帮助??????



#包括< iostream>

使用命名空间std;


int count;


main( )

{



for(int count_1 = 1; count_1< = 10; count_1 ++)

{

for(int count_2 = 1; count_2< = count_1; count_2 ++)

cout<<" *" ;;

cout<< endl;

}


cout<< " \ n";


for(int count_3 = 1; count_3< = 10; count_3 ++)

{

for(int count_4 = 10; count_4> = count_3; count_4--)

cout<<" *" ;;


cout<<结束;


}


cout<< \ n按q然后按Enter键退出 - >" ;; //

char dummy;

cin>>假; //等待输入

返回0;


} //主要

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


请帮助任何人! !!!!


谢谢,

Shelbee

Hey all,
This is my first post. I am really hoping that someone out there has a solution to my C++ coding problem...

This is my code and what I have to do...
I think it is rows of 1 - 10 and then back

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

//These histograms are supposed to print beside eachother like this:

//* ******************** *
//** ********* ********* **
//*** ******** ******** ***
//**** ******* ******* ****
//***** ****** ****** *****
//****** ***** ***** ******
//******* **** **** *******
//******** *** *** ********
//********* ** ** *********
//*********** ***********
//but I can''t make them go beside eachother. My code below makes two of them,
//but they are one under the other!! Not what I need....

//HELP??????



#include <iostream>
using namespace std;

int count;


main()
{



for(int count_1=1;count_1<=10;count_1++)
{
for(int count_2=1;count_2<=count_1;count_2++)
cout<<"*";

cout<<endl;
}

cout << "\n";

for(int count_3=1;count_3<=10;count_3++)
{
for(int count_4=10;count_4>=count_3;count_4--)
cout<<"*";

cout<<endl;

}


cout << "\nPress q and then Enter to quit-->"; //
char dummy;
cin >> dummy; //Wait for input
return 0;

} // main
************************************************** *****************************************

Help anyone, please!!!!!!!

Thanks,
Shelbee

推荐答案

这一行


cout<< endl;


和这一行


cout<< \ n;


是等效的并将输出移动到一个新行。


如果你不想从新行开始然后不要运行这行代码。
This line

cout<<endl;

and this line

cout << "\n";

are equivilent and moves the output onto a new line.

If you don''t want to start on a new line then don''t run this line of code.


嘿,

感谢您的回复。


我试过,刚刚再次,然后它运行其中一个三角形,另一个全部在一行长的星号的第一行...!大声笑它让我疯了!我想把头发拉出来,但我觉得好笑!大声笑帮助......?


再次被困......?

Shelbee
Hey,
Thanks for responding.

I tried that, just now again, and then it runs one of the triangles and the other is all on the first line in one long line of asterisks...! LOL It''s making me crazy!! I thought about pulling my hair out, but I would look funny!! LOL HELP...?

Stuck again...?

Shelbee


如果你想一想,你不能为你已经输出的内容添加线条。我相信你要做的就是将三角形添加到你已输出的内容中。


我相信你所做的相当于尝试这样做:


cout<< 超级;

cout<< endl;

cout<< 男人;


你期待超人,但你得到超级/男人。


我认为你的整个算法需要精制。让我看看我能做些什么,我会回复你。
If you think about it, you can''t add lines to what you already outputted. What I believe you''re trying to do is add the triangles to what you''ve already outputted.

I believe what you are doing is equivalent to trying to do this:

cout << "super";
cout << endl;
cout << "man";

and you''re expecting superman, yet you get super/man.

I think your whole algorithm needs refining. Let me see what I can do, I''ll get back to you.


这篇关于for循环创建四个直角三角形直方图......帮助!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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