精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • 寫一個用矩形法求定積分的通用函數(shù),分別求正弦,余弦和自然對數(shù)冪函數(shù)的定積分.

    寫一個用矩形法求定積分的通用函數(shù),分別求正弦,余弦和自然對數(shù)冪函數(shù)的定積分.
    要能直接運行的代碼,能簡短的介紹幾句更好.
    其他人氣:487 ℃時間:2020-01-29 12:56:42
    優(yōu)質(zhì)解答
    #include
    #include
    double fun1(double x)
    {
    return sin(x);
    }
    double fun2(double x)
    {
    return cos(x);
    }
    double fun3(double x)
    {
    return exp(x);
    }
    double integral(double a,double b,double (*p)(double))
    {
    double step=(b-a)/10000;
    double x,sum=0;
    for(x=a;xsum+=step*(*p)(x);
    return sum;
    }
    main()
    {
    double a,b,sum,(*p)();
    int type;
    while(1)
    {
    printf("1:sin(x)\n2:cos(x)\n3:exp(x)\n0:結(jié)束\n");
    printf("請選擇被積函數(shù)的種類(輸入種類前的序號):\n");
    scanf("%d",&type);
    while(type<0||type>5)
    {
    printf("輸入的序號不正確,請重新輸入:");
    scanf("%d",&type);
    }
    switch(type)
    {
    case 1:p=fun1;break;
    case 2:p=fun2;break;
    case 3:p=fun3;break;
    case 0:return 0;
    }
    printf("請輸入積分上下限:\n下限a:");
    scanf("%lf",&a);
    printf("上限b:");
    scanf("%lf",&b);
    sum=integral(a,b,p);
    printf("第%d種函數(shù)在(%g,%g)范圍內(nèi)的定積分為:%f.\n",type,a,b,sum);
    }
    }
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點,以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版