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開發