UVA 10098 Generating Fast

来源:互联网 发布:深圳人工智能企业 编辑:程序博客网 时间:2024/05/18 00:06

UVA 10098 Generating Fast

题目大意:给出字符串,输出这个字符串的全部排列,无重复

解题思路:qsort后用next_permutation输出

#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;char str[100];int cmd(const void *a, const void *b) {    return *(char *)a - *(char *)b;}int main() {    int n;    cin >> n;    getchar();    while(n--) {        gets(str);        qsort(str, strlen(str), sizeof(char), cmd);        printf("%s\n", str);        while(next_permutation(str, str + strlen(str))) {            printf("%s\n", str);        }        printf("\n");    }}
0 0
原创粉丝点击