[排列]poj1256
来源:互联网 发布:php 读取json对象 编辑:程序博客网 时间:2024/05/22 06:24
题意:
给出一个串,要求按照字典序输出所有排列。
分析:
直接利用STL 里的next_permutation()就好,重新定义一个cmp函数,没有把cmp放进next_permutation(),我都WA哭了。。。
#include <cstdio>#include <cstring>#include <cmath>#include <iostream>#include <vector>#include <map>#include <queue>#include <algorithm>#define read freopen("q.in","r",stdin)#define LL long long#define maxn 35using namespace std;bool cmp(char x,char y){ if(tolower(x)!=tolower(y))return tolower(x)<tolower(y); else return x<y;}int main(){ //read; //cout<<'a'-'A'<<endl; int t; cin>>t; while(t--) { char str[maxn]; cin>>str; int len=strlen(str); sort(str,str+len,cmp); do { printf("%s\n",str); }while(next_permutation(str,str+len,cmp)); }}
0 0
- [排列]poj1256
- poj1256(全排列)
- POJ1256--全排列
- poj1256 dfs(全排列)
- POJ1256
- POJ1256
- poj1256
- poj1256
- POJ1256
- POJ1256 Anagram
- poj1256 Anagram
- poj1256(STL--next_permunation)
- POJ1256 (C++ compare函数)
- 1poj1256(全排序)
- Area(Pick定理POJ1256)
- poj1256 Anagram (next_permutation())
- POJ1256 Anagram(回溯法)
- poj1256 tolower函数
- 智能家居---遥控器APP
- 【Your Are Real Stewart】五月“啦啦啦”英语总结
- 强连通分量的三种算法
- js计时器
- Linux 进程的理解
- [排列]poj1256
- boost circular_buffer的使用
- 嵌入式学习笔记201-Linux kernel动起来
- (15.1.1)女人身上的“互联网思维”——女神商业逻辑
- 双冒号 冒号 在c++/c中的用法
- Ascii Table 不同系统中换行符的区别
- 修改oracle数据库表字段类型,处理ORA-01439错误
- Android后台处理最佳实践(Best Practices for Background Jobs)
- asa 5510 MQC方式对每个IP进行限速、某网段限速、某些IP进行限速