⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 二重积分函数.cpp

📁 4个关于二维积分函数的C程序
💻 CPP
字号:
#include <iostream.h>
#include <math.h>

float f1( float x,float y )                               //定义被积函数 1+x^2
  { float z;
  
    z=1+pow(x,2)+y;
    return z;
    }

   //////////////////////////////////////////////////////
   // *fun被积函数;b,a第一维的上下限;d,c第二维的上下限 //
   // m第一维的距离等分数;n第二维的距离等分数;         //
   //////////////////////////////////////////////////////
float integral(float (*fun)(float ,float ),float a, float b ,float c, float d,int m,int n)
  { float s,h1,h2,y;

    s=((*fun)( a,b )+(*fun)( c,d ))/2.0;
    h1 =(b-a)/m;
    h2 =(d-c)/n;
    for ( int i=1; i<m; i++ )
      for ( int j=1; j<n; j++ )
         s =(2*s+(*fun)( a+i*h1 ,b+j*h2)+(*fun)( a+(i+1)*h1 ,b+(j+1)*h2))/2;
    y=s*h1*h2;
    return y;  }


void main (  )
  {  int m,n;
     float c;
     cout << "\nplease input the value of m: ";
     cin >> m;
     cout << "\nplease input the value of n: ";
     cin >> n;
     cout << "\nthe value of integral:   ";
     c =integral( f1,1.0,3.0,0.5,1.0,m,n );

     cout << c;
     cin >> c;
         }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -