#include<iostream.h>
int main()
{
for(int x =0; x < 8; x++)
{
for(int y = 7; y >= 0; y--)
{
if(x >= y)
{
cout<<"* ";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
for(int i =0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
if(i < j)
{
cout<<"* ";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
return 1;
}
输出结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
int main()
{
for(int x =0; x < 8; x++)
{
for(int y = 7; y >= 0; y--)
{
if(x >= y)
{
cout<<"* ";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
for(int i =0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
if(i < j)
{
cout<<"* ";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
return 1;
}
输出结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
本文展示了一个使用C++编写的程序,该程序能够打印出一个由星号(*)组成的特定图案。通过双重循环结构实现了上半部分从左下角到右上角逐渐减少的星号排列,下半部分则是从左上角到右下角逐渐增加的星号排列。
1004

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



