Description
FJ在沙盘上写了这样一些字符串:
A1 = “A” A2 = “ABA” A3 = “ABACABA” A4 ==“ABACABADABACABA” … …
你能找出其中的规律并写所有的数列AN吗?
Input
仅有一个数:N ≤ 26。
Output
输出相应的字符串AN,以一个换行符结束。输出中不得含有多余的空格或换行、回车符。
Sample Input
3
Sample Output
ABACABA
规律还是很明显的,string连接可以直接用“+”,这个很方便 。
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main(){
string s;
int n;
scanf("%d",&n);
string s = "A";
for(int i = 2;i <= n;i++)
{
char d = 'A' + i - 1;
s = s + d + s;
}
cout<<s<<endl;
return 0;
}