[蓝桥杯2016初赛]搭积木-枚举,next_permutation
生活随笔
收集整理的這篇文章主要介紹了
[蓝桥杯2016初赛]搭积木-枚举,next_permutation
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼如下:
#include <iostream> #include <algorithm> using namespace std;int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};bool check() {if (a[0] > a[1] && a[0] > a[2] &&a[1] > a[3] && a[1] > a[4] &&a[2] > a[4] && a[2] > a[5] &&a[3] > a[6] && a[3] > a[7] &&a[4] > a[7] && a[4] > a[8] &&a[5] > a[8] && a[5] > a[9])return true;return false; }int main() {int cnt = 0;do {if (check())cnt++;} while (next_permutation(a, a + 10));cout << cnt << endl;return 0; }總結
以上是生活随笔為你收集整理的[蓝桥杯2016初赛]搭积木-枚举,next_permutation的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么设计手机app过程(怎么设计手机ap
- 下一篇: [蓝桥杯2016初赛]寒假作业-next