感觉不太可,我补全代码,这种好像不能保证字母输出的顺序 #include<iostream> #include<string> #include<algorithm> /* 以abc为例 第一个数字 a b c 第二个数字 a b c 第三个数字 a b c */ using namespace std; string s; void swaps(char & x, char & y){ char tmp = x; x = y; y = tmp; } void Factorial(string str,int l, int r){ if(l == r){ cout << str << endl; return; } for(int i = l; i <= r; i++){ swaps(str[l],str[i]); Factorial(str,l+1,r); swaps(str[l],str[i]); } } int main(){ cin >> s; sort(s.begin(),s.end()); cout << s << endl; Factorial(s,0,s.size()-1); return 0; }</algorithm></string></iostream>
点赞

相关推荐

06-27 18:45
中山大学 Ruby
25届应届毕业生,来广州2个礼拜了,找不到工作,绝望了,太难过了…
应届想染班味:9爷找不到工作只能说明,太摆了或者太挑了。
点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
05-28 12:15
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务