title: basic exercises FJ string
categories:
- ACM
- Recursive
tags: - logic
- Preorder
date: 2020-03-14 16:05:02
Careful observation is in order binary tree traversal
topic
Questions basic exercises FJ string
Resource constraints
Time limit: 1.0s Memory Limit: 512.0MB
Problem 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?
Input Format
Only a few: N ≤ 26.
Output Format
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
Spearheading
algorithm
#include<stdio.h>
#include<iostream>
using namespace std;
void p(char c)
{
if(c=='A')
{
cout<<c;
return ;
}
p(c-1);
cout<<c;
p(c-1);
}
int main()
{
int n;
while(cin>>n)
{
p('A'-1+n);
cout<<endl;
}
}