POJ1146
这题就是求字典序的下一个排列 用STL里的next_permutation函数就能轻松解决
处理过这种问题 在加上sort函数 很巧妙的解决了问题
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char yl[55],as[55];
while(~scanf("%s",yl)&&strcmp(yl,"#")!=0)
{
int len=strlen(yl),n=0;
strcpy(as,yl);
sort(as,as+len);
next_permutation(yl,yl+len);
if(strcmp(yl,as)==0)
cout<<"No Successor"<<endl;
else
cout<<yl<<endl;
}
return 0;
}
最后更新:2017-04-04 07:03:32
上一篇:
BookService数组调用
下一篇:
ActivityGroup中出现的Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@
云栖玖着 委实难得一见!在杭州竟然还有这样的139㎡小排!
架构风格
智能电表变炸弹:物联网时代供电设施安全性引关注
云栖现场,哪些数据相关公司亮相?
svn:could not open the requested svn f 解决
《STM32库开发实战指南:基于STM32F4》----第3章 初识STM32 3.1 什么是STM32
【云周刊】第139期:阿里年会黑科技全揭秘:IoT手环、人脸识别验票、大屏弹幕互动等“十八般武艺”轮番上阵
解密亚洲诚信如何做到HTTPS的最佳安全实践
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE:扫描指定文件
android 之ndk开发