当前位置:网站首页>C语言求积分的近似值
C语言求积分的近似值
2022-08-08 21:02:00 【Kichlvichn·хуту】
/** 用梯形法求积分的近似值 **/
#include"stdio.h"
#include"math.h"
float seekIntegral(float a, float b, int n)
{
float f1 = 0, f2 = 0;
float s = 0;
float deta, x;
x = a;
deta = (b - a) / n;
f1 = sin(x) + x;
for (int i = 0; i < n; i++)
{
x += deta;
f2 = sin(x) + x;
s += (f2 + f1) * deta / 2;
f1 = f2;
}
return s;
}
void main()
{
float s1,s2;
s1 = seekIntegral(0, 10, 60);
s2 = seekIntegral(0, 10, 60000);
printf("%.6f\n", s1);
printf("%.6f\n", s2);
}
边栏推荐
- pytorch实现数据集读取/下载
- The new database is online | CnOpenData information transmission, software and information technology service industry basic information data of industrial and commercial registered enterprises
- Kotlin - learn the fifth day of the Handler
- Introduction to GeoServer: 01-Introduction
- 3 MapReduce简单原理
- 并发和并行——从线程,线程池到任务
- Kotlin study notes
- 推荐7款好用的Visual Studio扩展
- [MEF]第04篇 MEF的多部件导入(ImportMany)和目录服务
- 【转发与重定向(二)】
猜你喜欢
随机推荐
Fastdata极数:元宇宙报告2022——Hello Metaverse
【idea_取消自动import .*】
【Oracle的NVL函数用法】
【导出PDF-项目应用】
Kotlin学习笔记
amd和Intel的CPU到底哪个好?
[MEF]第05篇 MEF的目录(Catalog)筛选
EasyExcel上传文件并使用Postman测试
阿里云祝顺民:算力网络架构的新探索
window下socket(TCP)控制台程序
Little knowledge about KotlinAndroid encounters
numpy
Process实现守护线程
文档图像二值化DIB_paper_2(更新中...)
澳洲ABM创新模式将销售代理权给到个体,让利消费者
GeoServer Getting Started Learning: 06-Publishing Multi-level TIF Map Data
Use fontforge to modify font, keep only numbers
pytorch实现数据集读取/下载
Kotlin reflection
1天搞定单片机中断——基础知识大全







