学c++的时候看到的例子,例图是四行,但我打出来,就只有三行。
int main()
{
int i,j,n=4;
for(i=1;j<=n;i++)
{
for(j=1;j<=30;j++)
cout<<' ';
for(j=1;j<=8-2*i;j++)
cout<<' ';
for(j=1;j<=2*i-1;j++)
cout<<'*';
cout<<endl;
}
为什么这段代码,只能输出3行啊。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
叒宇 2020-03-09 11:37关注#include<iostream> using namespace std; int main() { int i, j, n = 4; for (i = 1; i <= n; i++)//抄错了,这里的j应该是i { for (j = 1; j <= 30; j++) cout << ' '; for (j = 1; j <= 8 - 2 * i; j++) cout << ' '; for (j = 1; j <= 2 * i - 1; j++) cout << '*'; cout << endl; } }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报