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;
}


目录
相关文章
poj 3620
题意:给出一个矩阵,其中有些格子干燥、有些潮湿。       如果一个潮湿的格子的相邻的四个方向有格子也是潮湿的,那么它们就可以构成更大       的湖泊,求最大的湖泊。       也就是求出最大的连在一块儿的潮湿的格子的数目。
555 0
|
人工智能 BI
poj-3185-开关问题
描述   牛一行20他们喝的水碗。碗可以那么(面向正确的为清凉水)或颠倒的(一个位置而没有水)。他们希望所有20个水碗那么,因此用宽鼻子翻碗。   嘴太宽,他们不仅翻转一碗还碗的碗两侧(总共三个或三个——在两端的情况下碗——两碗)。
786 0
|
JavaScript
POJ 2027 No Brainer
Problem Description Zombies love to eat brains. Yum. Input The first line contains a single integer n indicating the number of data sets.
844 0
|
机器学习/深度学习
|
算法 计算机视觉
最小割-poj-2914
poj-2914-Minimum Cut Description Given an undirected graph, in which two vertices can be connected by multiple edges, what is the size of the minimum cut of the graph? i.e. how many edges must b
1534 0