当前位置:网站首页>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);
}
边栏推荐
- Kotlin学习笔记
- Bluu Seafood launches first lab-grown fish products
- numpy
- Little knowledge about KotlinAndroid encounters
- 2 Scrapy
- fastapi-实战-综述
- rancher坑记录
- 编译原理——逆波兰式分析程序(C#)
- Non-resolvableparent POM for xxxx: Could not find artifact xxx and ‘parent.relativePath‘ points at
- Getting Started with GeoServer: 04-Publishing Shapfile Map Data
猜你喜欢
随机推荐
[MEF]第04篇 MEF的多部件导入(ImportMany)和目录服务
Flask 教程 第十章:邮件支持
Kotlin annotations
推荐7款好用的Visual Studio扩展
ssh 登录connectction reset by peer
Bagging、Boosting、Stacking集成学习代码
Socket (udp) console program under window
Protobuf框架与WebAPI
GeoServer Getting Started Learning: 06-Publishing Multi-level TIF Map Data
GeoServer introductory learning: 05-Multi-level MBTiles specification data release
drf-树形结构的model的序列化显示
GeoServer introductory study: 07 - release a larger multi-tiered TIF map data
Simple Swing interface notes
Kotlin's JSON format parsing
[The browser opens the exported excel]
GeoServer入门学习:06-发布多层级TIF地图大图数据
矩阵相乘
numpy
用固态U盘让你的办公环境随身移动
Bluu海鲜公司推出首批实验室培育的鱼类产品