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

2015-07-20 17:09:36 ? 作者: ? 浏览: 8
_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; } 
     
    
   
  


?

?

?

?

?

?

-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: