Saturday, April 4, 2015

146 - ID Codes (UVa)

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000
#define pf printf
#define sf scanf

int main()
{
    char s[MAX];
    int len;
    while(cin >> s)
    {
        cin.ignore();
        if(s[0]=='#') break;
        len = strlen(s);

        if(next_permutation(s, s+len))
            cout << s << endl;
        else
            cout << "No Successor" << endl;
    }
    return 0;
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...