描述
分析
找规律的问题,下面的串是两个上面的串夹着第 n 个英文字符。
使用C++ 的string 的加法运算符重载可以达到拼接两个串的作用。
代码
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
while (cin >> n) {
string str = "";
string base = "A";
for (int i = 0;i < n;i++) {
str = str + base + str;
base[0] += 1;
}
cout << str << endl;
}
return 0;
}