• POJ 1146 ID Codes (STL)


    ID Codes
     

    STL知识点:

    给你一个字符串,求用这个字符串重新组合后,比这个字符串大的下一个字符串。

    例:

    abaacb   ->   ababac
    cba -> abc
    C++:
      next_permutation(a, a+len); 当然,prev_permutation就是求前一种排列组合的了。
    POJ 1146 Code:
     1 #include <map>
     2 #include <stack>
     3 #include <queue>
     4 #include <math.h>
     5 #include <stdio.h>
     6 #include <string.h>
     7 #include <iostream>
     8 #include <limits.h>
     9 #include <algorithm>
    10 #define LL long long
    11 #define min(a,b) (a>b?b:a)
    12 #define max(a,b) (a>b?a:b)
    13 #define eps 1e-9
    14 #define INF 1 << 30
    15 using namespace std;
    16 
    17 void run()
    18 {
    19     char s[100], str[100];
    20     while(~scanf("%s", s))
    21     {
    22         if(!strcmp(s, "#"))
    23             break;
    24         int len = strlen(s);
    25         strcpy(str, s);
    26         sort(str, str+len);
    27         next_permutation(s, s+len);
    28         if(!strcmp(str, s))
    29             printf("No Successor
    ");
    30         else
    31             printf("%s
    ", s);
    32     }
    33 }
    34 
    35 int main(void)
    36 {
    37     run();
    38 
    39     return 0;
    40 }
    ID Codes
  • 相关阅读:
    1289 大鱼吃小鱼
    install ios开发环境
    Xcode_5
    嵌入式学习_AD学习篇
    课务IOS概述_1
    动态规划入门(2):01背包问题
    Python记之薄暮笔记
    线段树进阶:权值线段树
    动态规划入门(1):最长递增子序列
    python记之Hello world!
  • 原文地址:https://www.cnblogs.com/Silence-AC/p/3462077.html
Copyright © 2020-2023  润新知