首页 > 代码库 > 组合排列
组合排列
Input
Input contains a single line with all labels of the requested goods (in random order). Each kind of goods is represented by the starting letter of its label. Only small letters of the English alphabet are used. The number of orders doesn‘t exceed 200.
Output
Output will contain all possible orderings in which the stores manager may visit his warehouses. Every warehouse is represented by a single small letter of the English alphabet -- the starting letter of the label of the goods. Each ordering of warehouses is written in the output file only once on a separate line and all the lines containing orderings have to be sorted in an alphabetical order (see the example). No output will exceed 2 megabytes.
Sample Input
bbjd
Sample Output
bbdjbbjdbdbjbdjbbjbdbjdbdbbjdbjbdjbbjbbdjbdbjdbb
函数生成排列组合序列
#include <stdio.h>#include <string.h>#include <algorithm>#include <iostream>using namespace std;int main() { char s[300]; int len; while(scanf("%s", s)!=EOF) { len = strlen(s); sort(s, s+len); do { printf("%s\n", s); }while(next_permutation(s, s+len)); } return 0;}
组合排列
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。