C++语言中一些可能会用到的函数及头文件

<algorithm>

  • upper_bound/lower_bound
    • code
      upper_bound(a + 1, a + n + 1, w);//查找第一个大于w的位置
      lower_bound(a + 1, a + n + 1, w);//查找第一个大于等于w的位置
      

<functional>

  • greater / less

    • code

      sort(a + 1, a + n + 1, greater<int>());//从大到小排序
      sort(a + 1, a + n + 1, less<int>());//其实这个没必要,因为sort默认的就是从小到大
      

<cctype>

  • isdigit 判断是否为数字,有些快读中会用到
    • code
      char c;
      cin >> c;
      puts(isdigit(c) ? "YES" : "NO");//如果是数字,输出YES
      

<bits/stdc++.h>

  • “万能头”,不过好像有包含不到的,不过包含不到的也用不上。
原文地址:https://www.cnblogs.com/Z8875/p/13256014.html