打印1棱形
打印一棱形
#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;
}
输出结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
#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;
}
输出结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*