c++硬核学习 一些数学运算 用cmake

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_41616600/article/details/99990767

一些cmath的数学运算,我很懒,所以。。。。
在这里插入图片描述

例如

// helloworld.cpp: 定义控制台应用程序的入口点。
//
#include <iostream>
#include <cmath>
using namespace std;
//命名空间

int main()
{

    int c=100;
    double b = 5.12;
    short k = -5;
    cout << sin(c) << "    " << typeid(sin(c)).name() << "    " << typeid(c).name() << endl;
    cout << cos(c) << "    " << typeid(cos(c)).name() << "    " << typeid(c).name() << endl;
    cout << tan(c) << "    " << typeid(tan(c)).name() << "    " << typeid(c).name() << endl;
    cout << log(c) << "    " << typeid(log(c)).name() << "    " << typeid(c).name() << endl;
    cout << pow(c,b) << "    " << typeid(pow(c,b)).name() << "    " << typeid(c).name() << typeid(b).name() << endl;
    cout << abs(k) << "    " << typeid(abs(k)).name() << "    " << typeid(k).name() << endl;
    cout << fabs(k) << "    " << typeid(fabs(k)).name() << "    " << typeid(k).name() << endl;
    cout << floor(c) << "    " << typeid(floor(c)).name() << "    " << typeid(k).name() << endl;

    return 0;
}

输出

-0.506366    double    int
0.862319    double    int
-0.587214    double    int
4.60517    double    int
1.7378e+10    double    intdouble
5    int    short
5    double    short
100    double    short

猜你喜欢

转载自blog.csdn.net/qq_41616600/article/details/99990767
今日推荐