FJ string
Description
FJ wrote some strings on the sand table: A1 = "A" A2 = "ABA" A3 = "ABACABA" A4 = "ABACABADABACABA"…… Can you find the pattern and write all the series AN?
Input
There is only one number: N ≤ 26.
Output
Please output the corresponding string AN, ending with a newline character. The output must not contain extra spaces, line feeds, or carriage returns.
Sample Input 1
3
Sample Output 1
Flats
Analysis: get new skills, convert char to string.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
string st = "";
for(int i = 1; i <= n; i ++)
{
string tp = st;
char xx = (char)((int)'A' + i - 1);
string str;
stringstream stream;
stream << xx;
str = stream.str();
st += str;
st += tp;
}
cout << st << endl;
return 0;
}