C Standard Library 標頭檔 math.h 中函數執行個體

來源:互聯網
上載者:User
/************************************************************************************************ * 名  稱: main.c * 功  能:C標準庫,標頭檔math.h學習,筆記 * 描  述:math.h中 提供的函數說明 * 作  者:JarvisChu * 時  間:2011-7-16 建立 *************************************************************************************************/#include <stdio.h>#include <math.h>int main(){    double iptr;    double d;    int extr;    //int i=0;    //絕對值函數,int abs(int x); double fabs(double x);    printf("abs:%d\n",abs(-1));    printf("fabs:%f\n\n",fabs(-1.45));/**********************************三角函數*********************************/    //正弦函數 double sin(double x);  x為弧度,其他三角函數類似    //沒有cot函數    printf("sin: %f\n",sin(1));    printf("cos: %f\n",cos(1));    printf("tan: %f\n", tan(1));    printf("arcsin: %f\n",asin(1/2));    printf("arccos: %f\n",acos(1/2));    printf("arctan: %f\n\n",atan(1));/**********************************雙曲函數*********************************/    //雙曲正弦 double sinh(double x);    //雙曲餘弦 double cosh(double x);    printf("sinh: %f\n",sinh(1));    printf("cosh: %f\n",cosh(1));    printf("tanh: %f\n\n",tanh(1));/**********************************科學計算*********************************/    //e^x    printf("e^x: %f\n",exp(1));    //log 10    printf("log10: %f\n", log10(100));    //log e    printf("loge: %f\n", log(4));    //x的y次方    printf("x^y: %f\n",pow(12,2));    //根號    printf("sqrt: %f\n",sqrt(4));    //求餘數    printf("fmod: %f\n",fmod(4.2,2));    //求不大於x的最大整數    printf("floor: %f\n\n",floor(4.1));    //把double型變數val分解成整數部分iptr和小數部分(傳回值),    //double modf(double val,double* iptr);    printf("modf:  整數%f;小數%f\n",iptr,modf(3.14,&iptr));    //把double型變數val分解:val = x* (2^n),n存放在eptr所指變數中,返回x(0.5 <=  x < 1)    d = frexp(5,&extr);    printf("5 = %2f * 2^%d\n",d,extr);    //隨機數    printf("rand: %d\n",rand());    return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.