/*
*copyrighe (c)2014,烟台大学计算机学院
*All rightes reserved
*文件名称:qwe.cpp
*作者:孙春红
*完成日期:2014年11月6日
*版本号:v1.0
*
*/
#include <iostream>
using namespace std;
void printchs (int m,char ch)
{
for (int j=1;j<=m;++j)
cout <<ch;
}
int main( )
{
int n=6;
for(int i=1; i<=n; ++i)
{
printchs(n-i,' ');
printchs (2*i-1,'*');
cout<<endl;
}
return 0;
}
运行结果:
知识点总结:
根据main函数中对printchs的调用,以及printchs的功能要求,编写出了函数。
学习心得:
对这个有点生疏,一开始就忘记要用函数的调用,结果总是出现error,最后使用函数的调用,才写出现在的结果。其实感觉起来还是循环语句使用起来比较方便。