Description
由样例可知,每个字符串长度是前一个字符串长度的2倍+1;
字符串顺序为 :An 某个字母 An
FJ在沙盘上写了这样一些字符串:
A1 = “A”
A2 = “ABA”
A3 = “ABACABA”
A4 = “ABACABADABACABA”
… …
你能找出其中的规律并写所有的数列AN吗?
Input
仅有一个数:N ≤ 26。
Output
请输出相应的字符串AN,以一个换行符结束。输出中不得含有多余的空格或换行、回车符。
Sample Input
3
Sample Output
ABACABA
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <
string>
using namespace std;
string miao[
30];
string n[
30] = {
"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 m;
miao[1] =
"A";
for(
int i =
2; i <=
27; i++
)
{
miao[i] = miao[i-
1]+n[i-
1]+miao[i-
1];
}
while(~scanf(
"%d", &
m))
{
cout<<miao[m]<<
endl;
}
return 0;
}
转载于:https://www.cnblogs.com/RootVount/p/10354943.html