作者lionel20002 (~小遥~)
看板EE_DSnP
标题[闲聊] C++ Algorithms
时间Tue Dec 4 00:32:15 2007
发现 C++ Algorithms 里面有两个关於排列的函式
bool next_permutation(iterator start,iterator end);
这个函式会帮你排下一个permutation
bool prev_permutation(iterator start,iterator end);
这个会排上一个permutation
用这个写超快的(大误)
PS.以上纯属娱乐,自己玩玩就好- -
PS2.我论:C++ Algorithms真是太强大了啊!(赞叹)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.240.249
1F:推 ric2k1:This is cool... I didn't know that. The complexity is 12/04 00:36
2F:→ ric2k1:linear for one sort, so the total will be quadric. 12/04 00:36
3F:嘘 ric2k1:想错了, 是 n*n!... 太慢罗... 12/04 00:39
4F:→ lionel20002:非递回会比递回慢?? 12/04 09:54
5F:推 ric2k1:递回应该比较慢, 其实 n*n! 也还OK啦, 12/04 10:49
6F:→ ric2k1:不知道有没有快一点的 algorithm? 12/04 10:50
7F:推 lionel20002:仿造了next_permutation()的功用自己写了一个函式 12/04 17:26
8F:→ lionel20002:只用了回圈,而且也不复杂(fuction本身约25行) 12/04 17:28
9F:→ lionel20002:大家可以往这个方向想想看!就能写出非递回排列了 12/04 17:29
10F:推 ric2k1:That's a good hint! Thank you. 12/04 19:05