1222: FJ的字符串 [水题]

时间:2023-03-08 20:59:06

1222: FJ的字符串 [水题]

时间限制: 1 Sec 内存限制: 128 MB

提交: 92 解决: 20 统计

题目描述

FJ在沙盘上写了这样一些字符串:

A1  =  “A”

A2  =  “ABA”

A3  =  “ABACABA”

A4  =  “ABACABADABACABA”

…  …

你能找出其中的规律并写所有的数列AN吗?

输入

仅有一个数:N  ≤  26。

输出

请输出相应的字符串AN,以一个换行符结束。输出中不得含有多余的空格或换行、回车符。

样例输入

2
3

样例输出

ABA
ABACABA

递归思想,感觉自己好弱

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h> using namespace std; void solve(int x)
{
if(x == )
{
printf("A");
}
else
{
solve(x-); printf("%c", 'A'+x-); solve(x-);
}
}
int main()
{
int n;
char ch[]; while(scanf("%d", &n) != EOF)
{
solve(n);
printf("\n");
} return ;
}