写一个用矩形法求定积分的通用函数
解: #include
main()
{ float integral(float(8p)(float),float a,float b,int n);
float a1,b1,a2,b2,a3,b3,c,(*p)(float);
float fsin(float);
float fcos(float);
float fexp(float);
int n=20;
printf(“Input a1,b1:”);
scanf(“%f,%f”,&a1,&b2);
printf(“Input a2,b2:”);
scanf(“%f,%f”,&a2,&b2);
printf(“Input a3,b3:”);
scanf(“%f,%f”,&a3,b3);
p=fsin;
c=integral(p,a1,b1,n);
printf(“The integral of sin(x) is:%f ”,c);
p=fcos;
c=integral(p,a2,b2,n);
printf(“The integral of cos(x) is :%f ”,c);
c=integral(p,a3,b3,n);
printf(“The integral of sin(x) is :%f ”,c);
}
float integral(float (*p)(float),float a,float b,int n)
{
int i;
floatx,h,s;
h=(b-a)/n;
x=a;
s=0;
for(i=1;i
main()
{ float integral(float(8p)(float),float a,float b,int n);
float a1,b1,a2,b2,a3,b3,c,(*p)(float);
float fsin(float);
float fcos(float);
float fexp(float);
int n=20;
printf(“Input a1,b1:”);
scanf(“%f,%f”,&a1,&b2);
printf(“Input a2,b2:”);
scanf(“%f,%f”,&a2,&b2);
printf(“Input a3,b3:”);
scanf(“%f,%f”,&a3,b3);
p=fsin;
c=integral(p,a1,b1,n);
printf(“The integral of sin(x) is:%f ”,c);
p=fcos;
c=integral(p,a2,b2,n);
printf(“The integral of cos(x) is :%f ”,c);
c=integral(p,a3,b3,n);
printf(“The integral of sin(x) is :%f ”,c);
}
float integral(float (*p)(float),float a,float b,int n)
{
int i;
floatx,h,s;
h=(b-a)/n;
x=a;
s=0;
for(i=1;i
【写一个用矩形法求定积分的通用函数】相关文章
2. 编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的
3. 写一个函数,求一个字符串的长度。在main函数中输入字符串,并输出其长度
4. 写一个函数,要求输入一个字符串和一个字符长度,对该字符串进行分隔
5. 请编写一个 C 函数,该函数在给定的内存区域搜索给定的字符,并返回该字符所在位置索引值
6. 面试自我介绍的通用技巧
7. 写一个方法,输入一个文件名和一个字符串,统计这个字符串在这个文件中出现的次数
10. 如何在Shell脚本中使用函数
本文来源:https://www.mianshiwenti.com/a13109.html
进入下载页面
﹝写一个用矩形法求定积分的通用函数﹞相关内容
- 写一个函数返回1+2+3+…+n的值(假定结果不会超过长整型变量的范围)
- 请写一个C函数,若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1
- 编写类String 的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 介绍一下Prototype的$()函数,$F()函数,$A()函数都是什么作用?
- 某IT外企面试题-二分法求方程!看看大家的C++功底
- Oracle面试题:如何把一个表从一个schema到另一个schema
- 用你熟悉的语言写一个连接ORACLE数据库的程序,能够完成修改和查询工作
- 请用用Java代码写一个堆栈
- 如何写一个自定义标签