/*
*copyright(c)2014,烟台大学计算机学院
*All right reserved.
*文件名称:test.cpp
*作 者:李晓凯
*完成日期:2014年11月6日
*版本号:v1.0
*
*问题描述:应用函数输出星号图
*输入描述:
*程序输出:星号图
*/
#include <iostream>
using namespace std;
void printstars(int m,char ch)
{
for (int j=1;j<=m;++j)
cout<<ch;
}
int main()
{
int n=6,i;
for (i=1; i<=n; ++i)
{
printstars(2*i-1,'*');
cout << endl;
}
return 0;
}
学习总结:刚刚学习了函数,还不太会用,费了好大劲才编出了这个星号图,以后要多多请教别人了!