zoukankan      html  css  js  c++  java
  • 全排列next_permutation()用法和构造函数赋值

    全排列next_permutation()用法


    在头文件aglorithm里

    就是1~n数组的现在的字典序到最大的字典序的依次增加。(最多可以是n!种情况)


    int a[n];
    do{
    }while(next_permutation(a,a+n));
    

    ####或者知道有多少种情况 比如排好序就有n!
    int a[n];
    sort(a,a+n);
    int chi=1;
    for(int i=1;i<=n;i++){
        chi*=i;
    }
    while(chi--){
        next_permutation(a,a+n);
    }
    

    ## 构造函数赋值

    过于菜了c++没学好,希望以后能慢慢这些填坑。。。(不定时更新,一些知识)

    strcut node{
        int x,y;
        node(){}
        node(int sx,int sy):x(sx),y(sy){}
        friend bool operator<(const node a,const node b){
            return a.y>b.y;
        }
    };
    
    int arr[10];//vector<int>arr;
    for(int i=0;i<10;i++)
    {
      arr[i]=i;
    }
    for(auto &a:arr)
    {
      cout << a;
    }
    

    我的头文件

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define il inline
    #define it register int
    #define inf 0x3f3f3f3f
    #define lowbit(x) (x)&(-x)
    #define pii pair<int,int>
    #define mak(n,m) make_pair(n,m)
    #define mem(a,b) memset(a,b,sizeof(a))
    #define mod 1000000007
    #define ios ios::sync_with_stdio(false)
    const int maxn=1e6+10;
    const int mo=1e9;
    ll ksm(ll a,ll b){if(b<0)return 0;ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}
    const double pi=acos(-1.0);
    int t;
    int n,m;
    int main() {
        scanf("%d",&t);
        while(t--){
            
        }
        return 0;
    }
    
    



    上海演了水哥的退役赛,心情不是很舒服,四题铜首,我也想成为像水哥以及~~对面那队(对面最起码沉迷算法七八年,我这一年菜鸡也只能尽全力靠近他们了,ps冠军队)~~的样子 我还要更加更加的努力才行。 以后每天没有早课就八点去实验室。每周至少两套题加补题,不想再那样无所作为了,靠自己,把自己的算法一点点往这个博客里添加,还有三年不到,至少这一次我要拼尽全力。
  • 相关阅读:
    Kudu vs HBase
    数据分析怎么更直观?十分钟构建数据看板
    The Beam Model:Stream & Tables翻译(上)
    3分钟掌握一个有数小技能:收入贡献分析
    猛犸机器学习开发实践
    SparkSQL大数据实战:揭开Join的神秘面纱
    细说Mammut大数据系统测试环境Docker迁移之路
    python中的闭包与装饰器
    import详解
    python中的with与上下文管理器
  • 原文地址:https://www.cnblogs.com/luoyugongxi/p/11938491.html
Copyright © 2011-2022 走看看