Sign-up....

哪位老师讲解一下

这个程序用来输出一个等边三角形:

#include <iostream>

using namespace std;

void main()

{

int n;

printf("Input n : ");

cin>>n;

for (int i=0;i<n;i++)

{

for(int j=0;j<n-i-1;j++)

cout<<" ";

for(j=0;j<2*i+1;j++)

cout<<"*";

cout<<endl;

}

}

Input n : 6

*

***

*****

*******

*********

***********

请问这个是怎么执行出来的????哪个老师给讲解一下!!!!

[327 byte] By [msdn] at [2007-8-14 13:02:52]
# 1 Re: 哪位老师讲解一下

void main()

{

int n;

printf("Input n : ");

cin>>n;

for (int i=0;i<n;i++) // 行控制

{

for(int j=0;j<n-i-1;j++) //控制空格输出

cout<<" ";

for(j=0;j<2*i+1;j++) //控制'*'的输出

cout<<"*";

cout<<endl;

}

}

lucymary1982 at 2005-5-2 11:08:59 >
# 2 Re: 哪位老师讲解一下

如果都这样问,以后谁还上CSDN.......

zzm7000 at 2005-5-2 12:13:55 >
# 3 Re: 哪位老师讲解一下

如果这样的问题你都想不明白,你可以问问你的同学或老师......没必要这来发帖吧...

没有打击楼主的意思,说说而已

zzm7000 at 2005-5-2 12:16:39 >
# 4 Re: 哪位老师讲解一下

……………………

qhfu at 2005-5-2 12:18:17 >
# 5 Re: 哪位老师讲解一下

收起来^^

yjm0105 at 2005-5-2 12:23:23 >
# 6 Re: 哪位老师讲解一下

呵呵。。。。。。。。。。。。

flying_dancing at 2005-5-2 14:06:28 >
# 7 Re: 哪位老师讲解一下

慢慢来。。

mostideal at 2005-5-2 14:11:40 >
# 8 Re: 哪位老师讲解一下

楼主好学,哈哈

flfljh at 2005-5-2 14:43:52 >
# 9 Re: 哪位老师讲解一下

我本将心向明月,耐何明月照沟渠!!!!!!

minlove2004 at 2005-5-2 15:30:04 >
# 10 Re: 哪位老师讲解一下

我们大家学程序开发开始是不都是这样吗?不要急,慢慢来,

Harvey_s at 2005-5-13 18:30:55 >

C/C++

All Classified