丐丫


私信TA

用户名:uq_23409443706

访问量:612

签 名:

等  级
排  名 44623
经  验 290
参赛次数 0
文章发表 1
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n;

string str;

void BEswap(int l,int r)

{

    if(l==r||l>(n-1)/2)

        return;

    std::swap(str[l],str[r]);

    cout<<str<<endl;

    BEswap(l+1,r-1);

}

int main()

{

    cin>>n>>str;

    BEswap(0,n-1);

    cout<<endl<<str<<endl;

    return 0;

}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<iostream>
#include<algorithm>
using namespace std;
int len;
string s;
void recursion(int l,int r){
	if(l==r||l>(len-1)/2){//single character or recure over
		cout<<'\n'<<s<<'\n';
		return;
	}
	swap(s[l],s[r]);
	cout<<s<<'\n';
	recursion(l+1,r-1);
}
int main(){
	ios::sync_with_stdio(false);
	
	cin>>len>>s;
	recursion(0,len-1);
	
	return 0;
}
2022-02-10 13:23:16
  • «
  • 1
  • »