在学习 c++ 循环时,我遇到了一个有趣的任务,需要将以下图像输出到控制台:
结果以一种相当简单的方式显示了主要部分,但是额外的“星号”存在问题
int main()
{
int strok,colon;
for(strok = 5; strok >= 1; strok--)
{
for(colon = 1; colon <= strok; colon++)
putchar('*');
putchar('\n');
}
for(strok = 2; strok <= 5; strok++)
{
for(colon = 1; colon <= strok; colon++)
putchar('*');
putchar('\n');
}
}
https://ideone.com/XvUVch