问题及代码:
/*
*Copyringht (c) 2014,烟台大学计算机学院
*All right reserved.
*文件名称: test.cpp
*作 者:马明城
*完成日期:2014年11月9日
*版本号: v1.0
*问题描述:将程序补充完整,使其输出星号图
*输入描述:
*程序输出:将程序补充完整,使其输出星号图
*/
#include <iostream>
using namespace std;
void printchs(char ch,int m)
{
for(int j=1; j<=m; ++j)
cout<<ch;
}
int main()
{
int n=6,i;
for(i=1; i<=n; ++i)
{
printchs(' ',n-i);
printchs('*',2*i-1);
cout<<endl;
}
return 0;
}
运行结果:
知识总结:继续努力