来源:点击打开链接 求字典序下一位,没有直接输出没有.全排列函数秒水过. #include <iostream> #include <algorithm> #include <cstring> #include <string> using namespace std; int main() { int testcase; string tar; while(cin>>tar && tar!="#") { if…
// 求下一个排列// 如果已经是最后一个排列// 就输出 No Successor// stl 或 自己写个 生成排列 我测试了下 两个速率是一样的.只是代码长度不同 /* #include <iostream> #include <string> #include<sstream> #include <cmath> #include <map> #include <stdio.h> #include <string.h>…
ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and ther…
ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7644   Accepted: 4509 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and ther…
/* * POJ_1146.cpp * * Created on: 2013年10月8日 * Author: Administrator */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; char s[60]; int l; bool get(){ int i = l - 1; int j; while(i…
题目大意:输入一个字符串.输出它的下一个字典序排列. 字典序算法思想: 1.从右向左寻找字符串找出第一个a[i]<a[i+1]的位置i; 2.从右向左找出第一个大于a[i]的元素a[j]; 3.swap(a[i],a[j]) 4.将a[i+1]......到a[stelen(a)]倒序 5.输出a 代码例如以下: #include<iostream> #include<cstdio> #include <cstring> #include<algorithm…
ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby…
题目链接: http://poj.org/problem?id=1146 题意: 给定一个字符串(长度不超过50), 求这个字符串的下一个字典序的字符串, 如果已经是最大字典序, 那么输出 "No successor". 分析: <algorithm>中有一个现成的next_permutation(begin, end), 对输入的字符串进行排列. 原型如下: template<class BidirectionalIterator> bool next_per…
题目链接:http://poj.org/problem?id=1256 解题报告: 1.sort函数是按照ASC11码排序,而这里是按照 'A'<'a'<'B'<'b'<...<'Z'<'z'排序. #include <iostream> #include <algorithm> #include <string> using namespace std; bool cmp(char a,char b) { char m=tolowe…
#include <iostream> #include <algorithm> #define MAXN 55 using namespace std; char _m[MAXN]; int main() { //freopen("acm.acm","r",stdin); int i; while(cin>>_m) { ) { break; } if(next_permutation(_m,_m+strlen(_m))) { ;…