求全排列,调用C++函数
来源:互联网 发布:淘宝强行退款 编辑:程序博客网 时间:2024/06/06 13:13
C -Orders
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uDescription
The stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are stored in the same warehouse (i.e. in the same building) labelled with this letter. During the day the stores manager receives and books the orders of goods which are to be delivered from the store. Each order requires only one kind of goods. The stores manager processes the requests in the order of their booking.
You know in advance all the orders which will have to be processed by the stores manager today, but you do not know their booking order. Compute all possible ways of the visits of warehouses for the stores manager to settle all the demands piece after piece during the day.
You know in advance all the orders which will have to be processed by the stores manager today, but you do not know their booking order. Compute all possible ways of the visits of warehouses for the stores manager to settle all the demands piece after piece during the day.
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<algorithm>#include<string.h>#include<iostream>using namespace std;int main(){ char s[1000]; int len; while(gets(s)!=NULL) { len = strlen(s); sort(s, s+len);//先对字符串进行由小到大排序 do { puts(s); } while(next_permutation(s, s+len)); } return 0;}
知识点:
next_permutation 函数: 这是一个求一个排序的下一个排列的函数,可以遍历全排列, 要包含头文件<algorithm>
比如:输入 acb
然后: 依次输出数列的顺序就会为 。 STL 果然强大。。。。。。
0 0
- 求全排列,调用C++函数
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列
- 求全排列函数 (next_permutation())
- 求全排列 D的小L 函数next_permutation ()
- 递归求全排列
- 递归求全排列
- 递归求全排列
- 回溯法求全排列
- 递归方法求全排列
- 求全排列问题
- ubuntu字符界面中文乱码
- vc6.0 中classview栏的所有类不见了,该怎么解决?删除.clw,.ncb.....等等,这些网络资源的方法根本不行
- POJ 1731 Orders(STL运用)
- Activity继承BaseActivity的使用(使用相同布局)
- How Tomcat work之第十五章之Digester之setting property
- 求全排列,调用C++函数
- headerview 滚动
- HDU 4324 Triangle LOVE 拓扑排序
- VxWorks 系统时间时区设置
- ISA95的抽象惯例
- ffplay parameters
- poj 1258 Agri-Net(最小生成树,普里姆算法)
- ios--MBProgressHUD(使用方式一)--在事件的执行过程中显示+指定显示时间长短
- TIANKENG’s restaurant