Basic exercises -FJ string


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

By submitting this question

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;
	}

}
Published 43 original articles · won praise 1 · views 928

Guess you like

Origin blog.csdn.net/qq_43985303/article/details/104865485