UVa 10098 - Generating Fast

来源:互联网 发布:mac卸载双系统 编辑:程序博客网 时间:2024/05/17 03:44

题目链接:UVa 10098 - Generating Fast

跟上道题用同样的方法。记得先排下序就行了。

#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int MAX_N = 10 + 5;int T;char a[MAX_N];int len;int cmp(const void *a,const void *b){    return *(char*)a - *(char*)b;}int main(){    cin>>T;    while(T--)    {        cin>>a;        len = strlen(a);        qsort(a,len,sizeof(a[0]),cmp);        do        {            cout<<a<<endl;        }        while(next_permutation(a,a+len));        cout<<endl;    }    return 0;}


0 0
原创粉丝点击