poj 1256 Anagram
2015-07-03 02:41
411 查看
http://poj.org/problem?id=1256
题意是说求出一个字符串的全排列,按字典序
需要注意的是字典序和传统意义上的字典序不同
重新定义了,A<a<B<b的顺序
需要自己重写cmp函数。
next_permutation好神....直接求出全排列.....
题意是说求出一个字符串的全排列,按字典序
需要注意的是字典序和传统意义上的字典序不同
重新定义了,A<a<B<b的顺序
需要自己重写cmp函数。
next_permutation好神....直接求出全排列.....
#include <algorithm> #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <cmath> #include <map> using namespace std; bool cmp(char a,char b) { char x = tolower(a); char y = tolower(b); if (x==y) { return a<b; } else return x<y; } int n; string st; int main() { cin>>n; while (n--) { cin>>st; sort(st.begin(),st.end(),cmp); do { cout<<st<<endl; }while (next_permutation(st.begin(),st.end(),cmp)); } return 0; }
相关文章推荐
- 「深入 Exchange 2013」08 代理、重定向、共存
- windows程序设计 第5版又发现新错误
- mongodb 学习笔记 09 -- shard分片
- 微动力WQ_V3.V20150311 UTF8商业版程序完整包免费下载
- struts2拦截器的实现原理及源码剖析
- Struts2拦截器 实现未登录拦截和权限控制
- struts2 角色权限 filter(过滤器)和interceptor(拦截器)
- Substring with Concatenation of All Words
- udp 调用connect函数
- Cell重用问题
- Oracle主键与复合主键的性能分析
- Kth Smallest Element in a BST
- map和list的用法:HashMap遍历(一)
- JSON构造和解析json-lib(一)
- 摘录-IT企业必读的200个.NET面试题-06 .NET中的高级特性
- java直接读取.zip压缩文件(一)
- 委托和事件的区别
- 走出软件作坊
- 12_Android中HttpClient的应用,doGet,doPost,doHttpClientGet,doHttpClient请求,另外借助第三方框架实现网络连接的应用,
- 12_Android中HttpClient的应用,doGet,doPost,doHttpClientGet,doHttpClient请求,另外借助第三方框架实现网络连接的应用,