# 如何用c语言算抛物线的长度,计算二次函数曲线的长度（非微积分方法）

1.[代码][C/C++]代码

#include

#include

using namespace std;

double curveLenth(double a, double b, double c, double x)

{

long double dx1, dx2, dy1, dy2, l = 0;

double i, h;

for (h = 0, i = 1; i <= (x * 100000); i++, h++)

{

dx1 = h / 100000, dx2 = i / 100000;

dy1 = a * dx1 * dx1 + b * dx1, dy2 = a * dx2 * dx2 + b * dx2;

l = l + hypot(dx2 – dx1, dy2 – dy1);

}

return l;

}

int main()

{

a:double a, b, c, x; //做个标记

cout << “请输入方程系数a b c:”;

cin >> a >> b >> c;

cout << “请输入曲线右端点x值：”;

cin >> x;

cout << “曲线长度为：” << curveLenth(a, b, c, x) << endl;

goto a; //这样程序运行完就不会退出了

return 0;

}

2.[文件] 抛物线长度计算.cpp ~ 714B     下载(19)

﻿#include

#include

using namespace std;

double curveLenth(double a, double b, double c, double x)

{

long double dx1, dx2, dy1, dy2, l = 0;

double i, h;

for (h = 0, i = 1; i <= (x * 100000); i++, h++)

{

dx1 = h / 100000, dx2 = i / 100000;

dy1 = a * dx1 * dx1 + b * dx1, dy2 = a * dx2 * dx2 + b * dx2;

l = l + hypot(dx2 – dx1, dy2 – dy1);

}

return l;

}

int main()

{

a:double a, b, c, x; //做个标记

cout << “请输入方程系数a b c:”;

cin >> a >> b >> c;

cout << “请输入曲线右端点x值：”;

cin >> x;

cout << “曲线长度为：” << curveLenth(a, b, c, x) << endl;

goto a; //这样程序运行完就不会退出了

return 0;

}

原文作者：Yungever
原文地址: https://blog.csdn.net/weixin_35215870/article/details/117210075
本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。