http://soj.me/4495

按字典序生成字符串的全排列

直接递归:

#include <iostream>
#include <string>
#include <cstring> using namespace std; int len;
bool ever[9];
string str; void permutation(string cur)
{
if(cur.size() == len)
{
cout<<cur<<endl;
return ;
}
for(int i=0;i<len;++i)
{
if(!ever[i])
{
ever[i] = 1;
permutation(cur + str[i]);
ever[i] = 0;
}
}
} int main()
{
while(cin>>str)
{
memset(ever,0,sizeof(ever));
len = str.size();
permutation("");
}
return 0;
}

Sicily 4495. Print permutations的更多相关文章

  1. python 生成排列、组合以及选择

    from <python cookbook> 19.15 任务 需要对一个序列的排列(permutation).组合(combination)或选择(selection)进行迭代操作.即使 ...

  2. python迭代器Itertools

    https://docs.python.org/3.6/library/itertools.html 一无限迭代器: Iterator Arguments Results Example count( ...

  3. python实现经典算法

    1,快速排序 题目形式:手写一下快速排序算法. 题目难度:中等. 出现概率:约50%.手写快排绝对是手撕代码面试题中的百兽之王,掌握了它就是送分题,没有掌握它就是送命题. 参考代码: def quic ...

  4. Python笔试——毕业旅行问题

    毕业旅行问题 小明目前在做一份毕业旅行的规划.打算从北京出发,分别去若干个城市,然后再回到北京,每个城市之间均乘坐高铁,且每个城市只去一次.由于经费有限,希望能够通过合理的路线安排尽可能的省一些路上的 ...

  5. 【leetcode】Permutations

    题目描述: Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the ...

  6. 大数求模 sicily 1020

        Search

  7. uva11630 or hdu2987 Cyclic antimonotonic permutations(构造水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Cyclic antimonotonic permutations Time Li ...

  8. [Leetcode][Python]47: Permutations II

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 47: Permutations IIhttps://oj.leetcode. ...

  9. [Leetcode][Python]46: Permutations

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 46: Permutationshttps://leetcode.com/pr ...

随机推荐

  1. 常用在线工具及API网址总结

    1.小图标在线查找 https://www.iconfinder.com/ 2.在线做图,Flowchart流程图,BPMN图,Org组织结构图等 http://www.processon.com/ ...

  2. Android之Adapter用法总结

    http://blog.csdn.net/fznpcy/article/details/8658155 Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器 ...

  3. Oracle字符编码

    .检查服务器编码: 执行SQL语法: Java代码 select * from v$nls_parameters; 或 Java代码 select * from nls_database_parame ...

  4. 几种常用单片机I/O口线的驱动能力

    摘要: 详细分析了几种常见单片机的I/O口结构,并据此分析其驱动能力大小 在控制系统中,经常用单片机的I/O口驱动其他电路.几种常用单片机I/O口驱动能力在相关的资料中的说法是:GMS97C2051. ...

  5. DELPHI 任务栏无EXE显示

    需要用到的一个函数: LONG SetWindowLong( HWND hWnd, int nIndex, LONG dwNewLong ); program Project; usesForms,  ...

  6. Hessian Servlet和Hessian Spring的简单应用

    转自: http://lancui.iteye.com/blog/935578 简介 相比WebService,Hessian更简单.快捷.采用的是二进制RPC协议(Binary),因为采用的是二进制 ...

  7. paip.QQ音乐导出歌单总结

    paip.QQ音乐导出歌单总结 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/attilax ...

  8. Python学习笔记6-异常捕获取

    #--encoding:utf-8-- try: float('abc') except Exception,e: print e try: float(1.2) except Exception,e ...

  9. varnish和squid的对比

    Varnish与Squid的对比  说到Varnish,不能不提Squid,Squid是一个高性能的代理缓存服务器,它和varnish之间有诸多的异同点,这里分析如下:  下面是他们之间的相同点:   ...

  10. C#中使用日志类,添加dll时出现错误

    警告 1 未能解析引用的程序集 “log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, proces ...