蓝桥杯 1461: [蓝桥杯][基础练习VIP]FJ的字符串 Easy only once *注意逐步迭代求和的思想
基本思想:
两种方式,递归构造和循环构造都可以;
循环构造在前面求递增前n项和的时候都有应用,所以一定要注意下;
自己总结不出来固定的一步构造方法才想到用递归的。
关键点:
逐步列式子进行计算;
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
string cst(int n) {
if (n == 1)
return "A";
char c = 'A' + n - 1;
return cst(n - 1) + c + cst(n - 1);
}
int main(){
int n;
cin >> n;
cout << cst(n) << endl;
}

浙公网安备 33010602011771号