6.3w+
社区成员
#include <iostream>
using namespace std;
void show(int num, int totalnum, int flag=0)
{
int indent = (totalnum-num);
if (flag == 0)
{
for (int i=0; i<indent; i++)
{
cout<<' ';
}
}
for (int i=0; i<num; i++)
{
cout<<"* ";
}
cout<<endl;
}
int main(void)
{
int NUM = 5;
for (int i=1; i<NUM; i+=1)
{
show(i, NUM);
}
cout<<endl;
for (int i=1; i<NUM; i+=1)
{
show(NUM-i, NUM );
}
cout<<endl;
for (int i=1; i<NUM; i+=1)
{
show(i, NUM, 1);
}
for (int i=2; i<NUM; i+=1)
{
show(NUM-i, NUM, 1);
}
return 0;
}