资源限制
内存限制:512.0MB C/C++时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s
问题描述
FJ在沙盘上写了这样一些字符串:
A1 = “A”
A2 = “ABA”
A3 = “ABACABA”
A4 = “ABACABADABACABA”
… …
你能找出其中的规律并写所有的数列AN吗?
输入格式
仅有一个数:N ≤ 26。
输出格式
请输出相应的字符串AN,以一个换行符结束。输出中不得含有多余的空格或换行、回车符。
样例输入
3
样例输出
ABACABA
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
int N;
cin>>N;
char c1[100000]="A";
char c5[100000]="A";
for(int i=1;i<N;i++)
{
char c2[100000]="A";
char c ='A'+i;
// cout<<c<<endl;
c2[0]=c;
// cout<<c2<<endl;
strcat(c1,c2);
// cout<<c1<<endl;
strcat(c1,c5);
memcpy(c5,c1,strlen(c1));
}
cout<<c5;
return 0;
}