zoukankan      html  css  js  c++  java
  • 常用函数

     运算符优先级参考站点 点我直达

    字符串与数字的互转:

    (1)atof 字符串→双精度浮点型

      double atof (const char* str);

    (2)atoi 字符串→整型

      int atoi (const char * str);

    (3)atol 字符串→整型  注意:long、int、long int 这三个都是4个字节的,也就是最大21 4748 3647。

      long int atol ( const char * str );

    (4)atoll 字符串→长整型  注意:long long占8位

      long long int atoll ( const char * str );

    (5)to_string 数字→string   注意:c++11的,无需对象,直接调用。

      string to_string (int val);  
      string to_string (long val);
      string to_string (long long val);
      string to_string (unsigned val);
      string to_string (unsigned long val);
      string to_string (unsigned long long val);
      string to_string (float val);
      string to_string (double val);
      string to_string (long double val);

    (6)sprintf 数字字符串        注意:第2和3个参数是对应的,可以换成其他想要输出的格式,能打印到stdout的都可以转成字符数组。

      sprintf(char *str, "%f", double d)

     (7)sscanf 从字符串中格式化读取    类似于scanf,只是这个是从第一个参数中读取输入,除去第一个参数,其他的用法与scanf无异。如:sscanf(s,"%d",&n);

      int sscanf ( const char * s, const char * format, ...);

    数学函数:

     (1)exp 指数函数,即求ans=ex

      double exp (double x);

     (2)pow 求幂函数,即求ans=baseexponent

      double pow (double base, double exponent);

     (3)__gcd(参数1,参数2)  最大公约数  头文件 <bits/stdc++>

     
  • 相关阅读:
    DOM节点类型
    javascript中的变量、作用域
    this 不同情况指代的对象
    BOM对象节点
    浏览器兼容性
    总结
    javascript事件流讲解和实例应用
    7.20
    7.16总结
    飞机大战
  • 原文地址:https://www.cnblogs.com/xcw0754/p/4434286.html
Copyright © 2011-2022 走看看