首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

打印1棱形

2012-10-18 
打印一棱形#includeiostream.hint main(){for(int x 0 x 8 x++){for(int y 7 y 0 y--){if(x

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

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

热点排行