题意:给你一条字符串,让你输出字符串中字符的全排列,输出的顺序要按它给的奇葩的字典序。

题解:要输出全排列,暴力dfs可以过,但要注意题目的字典序以及相同字符的情况。如果用next_permutation()处理可以简单很多;我是先将字典序"A a B b...Z z"的每个字母赋予一个值,即从1 2 3...52。然后将给的字符串全部转换成对应的数值后,用next_permutation()进行全排列(当然 题目给的字典序有一定规律,所以也可以直接给next_permutation()写个cmp函数直接处理字符串)。

 /**
* @author Wixson
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <map>
#include <set>
const int inf=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-;
using namespace std;
typedef long long ll;
typedef pair<int,int> P; char str[];
char book[];
int a[];
void init()
{
for(int i=;i<;i++)
{
if(i%) book[i]='a'+i/;
else book[i]='A'+i/;
}
}
int main()
{
//freopen("input.txt","r",stdin);
init();
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%s",str);
n=strlen(str);
for(int i=;i<n;i++)
{
if(str[i]>='A'&&str[i]<='Z') a[i]=(str[i]-'A')*;
else a[i]=(str[i]-'a')*+;
}
//
sort(a,a+n);
do
{
for(int i=;i<n;i++) putchar(book[a[i]]);
putchar('\n'); }while(next_permutation(a,a+n));
}
return ;
}

最新文章

  1. Rafy 领域实体框架演示(4) - 使用本地文件型数据库 SQLCE 绿色部署
  2. iOS百度地图简单使用
  3. .Net程序员之Python基础教程学习----列表和元组 [First Day]
  4. 2-MSP430按键输入检测
  5. 2层Xml读取类
  6. wget ftp
  7. Java [leetcode 7] Reverse Integer
  8. hibernate 连接数据库时报错
  9. godaddy_关于产品退款
  10. 微信小程序开发之 下拉刷新,上拉加载更多
  11. [置顶] access函数-linux
  12. 兼容IE6及以上的导航栏子菜单栏滑过显示隐藏效果
  13. Django---请求、响应
  14. VUE插件总结
  15. smarty缓存
  16. 20172327 2018-2019-1 《第一行代码Android》第一章学习总结
  17. Java中String直接赋字符串和new String的区别 如String str=new String(&quot;a&quot;)和String str = &quot;a&quot;有什么区别?
  18. document.visibilityState 监听浏览器最小化
  19. postman—集成到jenkins
  20. 从零开始——MySql01

热门文章

  1. mybatis 中 foreach 的性能问题及调优
  2. 海量文本信息查Top-k
  3. linux对比两个文件的差异
  4. HTML TabIndex属性
  5. UDP网络程序实例
  6. html——细线表格
  7. JavaScript学习书签
  8. ImageMagick的下载和配置
  9. Linux之内核管理及故障排错
  10. python爬虫13 | 秒爬,这多线程爬取速度也太猛了,这次就是要让你的爬虫效率杠杠的