C++ STL next_permutation
来源:互联网 发布:mac os x 10.11.6 iso 编辑:程序博客网 时间:2024/05/29 18:24
/*next_permutation()返回的是布尔类型*/
#include<iostream>#include<algorithm>#include<string>using namespace std;int main(){ string str; cin>>str; sort(str.begin(),str.end()); cout<<str<<endl; while(next_permutation(str.begin(),str.end())) { cout<<str<<endl; } return 0;}
/*使用大数据测试的时候,发现标准C++的效率很差,换成C写效率将快一倍多*/
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int main(){ int length; char str[100]; gets(str); length=strlen(str); sort(str,str+length); puts(str); while(next_permutation(str,str+length)) { puts(str); } return 0;}
next_permutation()的函数原理如下:
template<class BidirectionalIterator>bool next_permutation( BidirectionalIterator _First, BidirectionalIterator _Last);template<class BidirectionalIterator, class BinaryPredicate>bool next_permutation( BidirectionalIterator _First, BidirectionalIterator _Last, BinaryPredicate _Comp );
- C++STL的next_permutation
- C++STL的next_permutation
- C++STL的next_permutation
- C++STL的next_permutation 的用法
- STL next_permutation
- 【STL】next_permutation
- [STL]next_permutation
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- 使用STL的next_permutation函数生成全排列(C++)
- C++STL中全排列函数next_permutation的使用
- C++STL中全排列函数next_permutation的使用
- C++STL中全排列函数next_permutation的使用
- 关于Java安全的书
- 实现ListView A~Z快速索引
- LeetCode - Merge Sorted Array
- 屌丝程序人生(上)
- 海量数据处理常用思路和方法
- C++ STL next_permutation
- 屌丝程序人生(下)
- Android中的Handler的用法
- MySql出现error:the security setting could not be applied
- hdu1978 How many ways
- NYOJ 题目161 取石子(四) 威佐夫博奕(Wythoff Game)
- 小for的Cocos2d-x学习笔记与感悟5之拖动(Touch)事件
- Android设置屏幕自动转屏
- 各大推荐引擎资料汇总