#include <iostream>
using namespace std;
int main()
{
int a=1,b=1,c=1,d=6;
for(a=1;a<=6;a+=1)
{
for(b=1;b<=a;b+=1)
cout<<" ";
for(c=1,d=7-a;c<=2*d-1;c++)
{
cout<<"*";
}
cout<<endl;
}
cout << "Hello world!" << endl;
return 0;
}
using namespace std;
int main()
{
int a=1,b=1,c=1,d=6;
for(a=1;a<=6;a+=1)
{
for(b=1;b<=a;b+=1)
cout<<" ";
for(c=1,d=7-a;c<=2*d-1;c++)
{
cout<<"*";
}
cout<<endl;
}
cout << "Hello world!" << endl;
return 0;
}
本文介绍了一个使用 C++ 编写的简单程序,该程序通过嵌套循环实现金字塔形状的打印,并在金字塔下方输出Hello World!。文章通过调整循环变量来控制输出的空格数和星号数,以此形成金字塔图案。
605

被折叠的 条评论
为什么被折叠?



