UVA - 146 - ID Codes (枚举排列)(二)

2015-07-20 17:09:36 · 作者: · 浏览: 10
_permutation本身可以判断是否到了最后一个按照字典序排列的序列,所以直接用next_permutation即可

?

AC代码:

?

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       using namespace std; char str[55]; int main() { while(scanf("%s", str), str[0] != '#') { int len = strlen(str); if(next_permutation(str, str + len)) printf("%s\n", str); else printf("No Successor\n"); } return 0; } 
     
    
   
  


?

?

?

?

?

?