zoukankan      html  css  js  c++  java
  • 组合排列

    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

    bbdj
    bbjd
    bdbj
    bdjb
    bjbd
    bjdb
    dbbj
    dbjb
    djbb
    jbbd
    jbdb
    jdbb
    

    函数生成排列组合序列
    #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
    ", s);
    		}while(next_permutation(s, s+len));
    	}
    	return 0;
    }
    



  • 相关阅读:
    安卓中期小作业
    安卓大作业UI预定搞
    实验3
    实验一总结
    实验8 SQLite数据库操作
    实验6 在应用程序中播放音频和视频
    实验4 颜色、字符串资源的使用
    实验四
    实验三
    实验二
  • 原文地址:https://www.cnblogs.com/yspworld/p/3989105.html
Copyright © 2011-2022 走看看