读书人

打印1棱形

发布时间: 2012-10-18 13:46:56 作者: rapoo

打印一棱形
#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;
}

输出结果:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*

读书人网 >编程

热点推荐