/*
*copyrighe (c)2014,烟台大学计算机学院
*All rightes reserved
*文件名称:qwe.cpp
*作者:孙春红
*完成日期:2014年11月6日
*版本号:v1.0
*
*问题描述:补充程序,输出星号图
*/
#include <iostream>
using namespace std;
void printstars(int m)
{
for (int j=1; j<=m; ++j)
cout<<'*';
}
int main( )
{
int n=6;
for(int i=1; i<=n; ++i)
{
printstars( 2*i-1);
cout<<endl;
}
return 0;
}
运行结果:
知识点总结:
学会使用简单的调用函数
学习心得:
这个代码类似于前几次写的输出星星图的代码,在上次的基础上使用了简单的调用函数知识。