怎么用c语言指针函数求长方体体积及正侧顶三面面积(指针)

怎么用c语言指针函数求长方体体积及正侧顶三面面积(指针),第1张

#include <stdioh>

double Volume(double len, double width, double height)

{

    return lenwidthheight;

}

double Area(double len, double width)

{

    return lenwidth;

}

int main()

{

    double (fun_v)(double l, double w, double height);

    double (fun_a)(double l, double w);

    double len;

    double width;

    double height;

    printf("Enter len, width, height of the cuboid: ");

    scanf("%lf%lf%lf", &len, &width, &height);

    fun_v = Volume;

    printf("Volume of this cuboid is %gm3\n", fun_v(len, width, height));

    fun_a = Area;

    printf("Three different area are %gm2 %gm2 %gm2\n",

            fun_a(len,width),fun_a(len,height),fun_a(width,height));

    return 0;

}

double atan(double x)

x 的反正切函数值tan-1x,传回的值在 [-pi/2,pi/2] 之间

double atan2(double y, double x)

y/x 的反正切函数值tan-1(y/x),传回的值在 [-pi, pi] 之间

arctanX的导数是1/(1+X²)这里的X=x/2复合函数求导,需要先求子函数的导数,即X'=1/2再乘上arctanX的导数所以所求导数是1/[2(1+x²/4)]

C语言中之数学函数

C语言提供了以下的数学函数,要使用这些函数时,在程序文件头必须加入:

#include

编译时,必须加上参数「-lm」(表示连结至数学函式库),例如「gcc -lm testc」。

函数之自变量与传回之值型别见自变量或函数前之型别宣告。

函数已经在「mathh」或其它标头档宣告过了,因此在使用时不必再加型别宣告,例如「y=sin(x);」,不用写成「y=double sin(double x);」。

函数说明

double sin(double x)

x 的正弦函数值

double cos(double x)

x 的余弦函数值

double tan(double x)

x 的正切函数值

double asin(double x)

x 的反正弦函数值 sin-1x,x的值在 [-1,1] 之间,传回的值在 [-p/2,p/2] 之间

double acos(double x)

x 的反余弦函数值cos-1x,x的值在 [-1,1] 之间,传回的值在 [-p/2,p/2] 之间

double atan(double x)

x 的反正切函数值tan-1x,传回的值在 [-p/2,p/2] 之间

double atan2(double y, double x)

y/x 的反正切函数值tan-1(y/x),传回的值在 [-p, p]

你问的这个很片面啊,如果是C语言中的 sqrt()函数,就是开方,当然是用C语言编的,C++也有很多同样的啊,像VB JAVA都有算法啊,windows就是用多种语言实现不同的功能的。。每种语言都有他自己的算法,也有自己的区别 ,就像C是面向过程,而C++是面向对象,C++有继承和多态等性质什么的,

#include<stdioh>

#include<mathh>

float dis(float x1,float y1,float x2,float y2)

{return sqrt((x1-x2)(x1-x2)+(y1-y2)(y1-y2));

}

float area(float x1,float y1,float x2,float y2,float x3,float y3)

{float a,b,c,p;

 a=dis(x1,y1,x2,y2);

b=dis(x1,y1,x3,y3);

c=dis(x2,y2,x3,y3);

p=(a+b+c)/20;

return sqrt(p(p-a)(p-b)(p-c));

}

int main()

{int i,j,n;

 float x[100],y[100],s=0;

 scanf("%d",&n);

 for(i=0;i<n;i++)

    scanf("%f%f",&x[i],&y[i]);

 for(i=0;i<n-2;i++)

  s+=area(x[i],y[i],x[i+1],y[i+1],x[(i+2)%n],y[(i+2)%n]);

printf("S=%4f\n",s);

return 0;

}

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/13493780.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2025-09-01
下一篇2025-09-01

发表评论

登录后才能评论

评论列表(0条)

    保存