蓝桥杯软件组C++程序设计
字母图形题
#include<iostream>
using namespace std;
char st[27] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
int main()
{
int n = 0;
int m = 0;
cin >> n >> m;
int len = 2 * m - 1;
char Array[27];
int a = 0;
for (int i = m - 1; i < len; i++)
{
Array[i] = st[a];
a++;
}
for (int i = 0; i < m - 1; i++)
{
Array[i] = Array[2 * m - 2 - i];
}
for (int i = 0; i < n; i++)
{
for (int j = m - 1-i; j <2*m-1-i; j++)
{
cout << Array[j];
}
cout << endl;
}
system("pause");
return 0;
}
结果图
以上就是本人所做的字母图形啦,代码思想类似于周期延拓,如有不懂可以评论区提问哦!
(第一次写博文,有误请多多谅解)~~~~