编程打印输出*金字塔

初步实现代码:

#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
cout<<setw(7-i);
for(j=1;j<=2*i-1;j++)
cout<<'*';
cout<<endl;
}
}

运行结果如图:

题型变换为输入行数,然后出现金字塔形状

posted @ 2012-04-07 22:27  iamvirus  阅读(1014)  评论(0编辑  收藏  举报