首页 > 其他 > 详细

7月7日助教题解 - 跳伞模拟器

时间:2020-07-06 10:39:25      阅读:53      评论:0      收藏:0      [点我收藏+]

技术分享图片

技术分享图片

 该式为 a 到 b  上 f ( x ) 的积分,考虑先分割,再求和,当分割的区间足够小的时候,分割的小矩形的面积和即为a到b上的积分

不妨设 小区间的长度为0.000001,直接暴力计算面积和即可。

技术分享图片
#include<math.h>
#include<stdio.h>
const double eps=1e-6;
double f(double x){
    return x*x/(log(x+1));
}
int main(){
    int a,b;
    while(~scanf("%d %d",&a,&b)){
        double d=0;
        for(double  x=a*1.0;x<=b*1.0;x+=eps){
            d+=f(x)*eps;
        }   
        printf("%.2lf\n",d);
    }
    return 0;
}
View Code

 

7月7日助教题解 - 跳伞模拟器

原文:https://www.cnblogs.com/littlerita/p/13253461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!