• 实用但不常用的函数


    求两个数的最大公因子(在algorithm头文件里):

    int __gcd(int a,int b)

    判断一个字符是否是英文字母或者数字:

    bool isalnum(char c)

    判断一个字符是否问英文字母:

    bool isalpha(char c)

    判断一个字符是否问数字:

    bool isdigit(char c)

    将字母转换为大写字母:

    int toupper(int c)

    将字母转换为小写字母:

    int tolower(int c);

    将字符串类型的以字符数组输出:

    1 printf("%s",s.c_str());

     字符串数组中查找某个字符串:

    1 int s.find(string s)//找到返回位置,没有访问string::npos

     将字符串切割:

    string s.substr(int index, int len)//index位位置,len为切割长度

     求dp数组中大于大于0的数量

    int count_if(dp+1,dp+1+m,bind2nd(greater_equal<int>(),0))

     求a数组中-1的数量

    int count(a,a+n,-1);

    上面一般用在bool中,求数组a中true的数量

    int count(a,a+n,true);

     二分查找ai >=k的最小指针

    int lower_bound(a,a+n,k)

     二分查找ai >k的最小指针

    int upper_bound(a,a+n,k)

     向下取整,返回一个不大于x的最大整数

    int floor(double x)

    向上取整,返回一个不小于x的最小整数

    int ceil(double x)

     cin,cout外挂

    std::ios::sync_with_stdio(false);

     将字符串转化为数字

    int atoi(char* s)

     立法根

    double cbrt(double x);

     栈开挂

    #pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈

     下一个全排列

    next_permutation(a, a+n)

    前一个全排列

    prev_permutation(a,a+n)

     当给定一个表达式求值时可以用python,如13年普及组T2

    print(input()%10000)

     bitset,用来做二进制问题。

    bitset<N> b;
    b.count() //1的个数
    b.set() //将所有的置位1
    b.reset() //将所有的置位0
    b.flip()  //取反

     数学公式:

    m个数的和为k
    x1+x2+...+xm = k    C(k+m-1,m-1)
    m个[0,n-1]的数和为k的数量:sum( (-1)^c * C(m , c) * C(m-1+k-n*c , m-1) );

    ------------------------------------------------------------------

    之后在更新

    ------------------------------------------------------------------

  • 相关阅读:
    dom4j的安装
    OWl本体语言学习笔记
    java学习笔记之链表(约瑟夫问题)
    C#打开指定文件夹及下载文件代码示例
    如何把phpStorm打造成自己的专属IDE
    SQL和TSQL之间的区别
    整数的划分(分治递归)
    整数的划分(变形)(分治递归)
    子序列 (Data_Structure)
    找球号(Hash)
  • 原文地址:https://www.cnblogs.com/xingkongyihao/p/7142479.html
Copyright © 2020-2023  润新知