<pre class="cpp" name="code">/*
*copyright (c) 2014 烟台大学计算机学院
*All right reseved
*文件名称:test.cpp
*作者:刘志力
*完成时间:2014年10月18日
*版本号:v1.0
*问题描述:使输出一系列的星号
*输入描述:nothing
*输出描述:输出一系列的星号
*/
#include <iostream>
using namespace std;
int main()
{ int a,b;
for(a=11;a>=1;a=a-2)
{
for(b=1;b<=a;b++)
{
cout<<"*"; }
cout<<endl;
}
cout<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a,b;
for(a=9;a>=1;a=a-1)
{
for(b=1;b<=a;b++)
{cout<<" ";}
for(;b<=10;b++)
{cout<<"*";}
cout<<endl;
}
cout<<"\n";
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a,b;
for(a=9;a>=1;a=a-1)
{
for(b=1;b<=a;b++)
{cout<<" ";}
for(;b<=19-a;b++)
{cout<<"*";}
cout<<endl;
}
for(a=1;a<=9;a++)
{
for(b=1;b<=a+1;b++)
{cout<<" ";}
for(;b<=18-a;b++)
{cout<<"*";}
cout<<endl;
}
cout<<"\n";
return 0;
}
、
本文介绍了使用C++编程语言输出不同形状的星号图案的方法。通过三个不同的示例展示了如何利用嵌套循环来创建特定的图案。这些示例包括递减的星号行、带空格的星号图案以及更复杂的对称星号图案。
5074

被折叠的 条评论
为什么被折叠?



