uva10098 Generating Fast

来源:互联网 发布:迅捷绑定mac地址 编辑:程序博客网 时间:2024/06/07 09:39
说实话 题目的意思我根本就不不懂。。。。看到给出的样例就知道是给出字符串的全排列

同样的 利用next_permutation()函数 (这个函数的作用就是给出你的数组的下一个全排列,对应的还有prev_permutation())函数

记得在得到数据后先进行一次sort

#include<stdio.h>#include<iostream>#include<algorithm>#include<string>using namespace std;bool cmp(char a, char b){return a < b;}int main(){int n;scanf_s("%d", &n);while (n--){string s;cin >> s;sort(s.begin(),s.end(),cmp);do{cout << s << endl;} while (next_permutation(s.begin(), s.end()));cout << endl;}return 0;}


0 0
原创粉丝点击