Subject description:
FJ in the sand table to write some string like this:
A1 = "A"
A2 = "ABA"
A3 = "ABACABA"
A4 = "ABACABADABACABA"
... ...
you can find out the rules and write them all columns AN it?
Enter a description:
Only a few: N ≤ 26.
Output Description:
Please output corresponding string AN, to a newline character. Output must not contain extra space or line feed, carriage return.
Sample input:
3
Sample output:
ABACABA
Problem-solving ideas:
Recursive solution.
AC Code:
#include <bits/stdc++.h>
using namespace std;
#define Up(i,a,b) for(int i = a; i <= b; i++)
void fun(int n)
{
if(n >= 1)
{
fun(n-1); //前半部分
printf("%c",'A'+n-1);
fun(n-1); //后半部分
}
}
int main()
{
int n;
cin >> n;
fun(n);
return 0;
}