PKU 1731 - Orders
問題概要
文字列が入力される。
この文字列の順列全てを辞書順で出力せよ。
解法
next_permutationやるだけで解けました。
プログラム
#include <iostream> #include <algorithm> #include <cstdio> using namespace std; int n; char s[1002]; int main(){ while(scanf("%s", s) != EOF){ n = strlen(s); sort(s, s + n); do{ puts(s); }while(next_permutation(s, s + n)); } }