Fork me on GitHub

Uva 10098 - Generating Fast

Problem C 
Generating Fast, Sorted Permutation

Input: Standard Input

Output: Standard Output

题目链接:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=1039

这题完全可以无视,但为什么通过率还没达到百分之五十呢?

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    
    int n;
    char p[14];
    scanf("%d", &n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%s", p);
        int len = strlen(p);
        sort(p, p+len);
        do
        {
            for(int j=0; j<len; ++j)
            printf("%c", p[j]);
            printf("\n");
        }while(next_permutation(p, p+len));
        printf("\n");
    }
    return 0;
}

 

posted @ 2013-04-16 07:11  Gifur  阅读(173)  评论(0)    收藏  举报
TOP