第11周项目1.4输出字母梯队图

来源:互联网 发布:阴茎上白色米粒知乎 编辑:程序博客网 时间:2024/06/05 10:51
/*

   *   copyright     (c)   2014   ,    烟台大学计算机学院

   *   all  rights   reserved  .

   *   文件名称   :    textst  .    cpp

   *    作者  :    孙旭明

   *     完成日期    :    2014年11月7日

   *     版本号    :     v1.0

   *

   *    问题描述 :用函数输出字母图

   *      程序输出    :    三角字母梯队图

   */

//调用函数printchs输出字母图
#include <iostream>

using namespace std;
//在下面写printchs函数的定义,功能是输出若干行字母组成的图像
void    printchs   ( int   m,char  ch)
 {
     for  ( int  j=1;j<=m;++j)
        cout <<ch;
        }
int main()
{
   int  n=6;//n代表要输出的行数
   int  i;
   //通过在下面的循环里调用printchs函数,输出图像
   for  (  i=1;i<=n;++i)
        {
        printchs   ( 2*i-1,80+1-i);//"80"亦可用"p"替代
        printchs    (n-i , ' ');

        cout  << endl;
}
    return 0;
}

学习心得:学会举一反三
 

 

 

0 0
原创粉丝点击