题目
3)在上面的程序中,只改动一处,输出右面的图形:
/*
*copyright (c) 2014,烟台大学计算机学院
*all rights reserved.
*文 件 名 : hanshuxinghao2.cpp
*作 者 :冷基栋
*完成日期 :2014年11月06号
*版 本 号 :v1.2
*/
#include <iostream>
using namespace std;
//在下面写printchs函数的定义,功能是输出一行若干个指定字符
void printchs(int a,char c)
{
for (int b=1; b<=a; b++)
cout<<c;
}
int main( )
{
char A=64;
int n=6; //n代表要输出的行数
int i;
//通过在下面的循环里调用printchs函数,输出右面的图
for(i=1; i<=n; ++i)
{
printchs(n-i,' ');
printchs(2*i-1,A+i) ;
cout<<endl;
}
return 0;
}
运行结果:
知识点总结:
常用字符与ASCII代码
学习心得:
好好学习天天向上