YTU 2404: C语言习题 求sinh(x)

版权声明:转载请附上原文链接哟! https://blog.csdn.net/weixin_44170305/article/details/90209959

不恋尘世浮华,不写红尘纷扰,不叹世道苍凉,不惹情思哀怨,闲看花开,静待花落,冷暖自知,干净如始。

题目描述

写一函数求sinh(x)的值,求sinh(x)的近似公式为 sinh(x) = (ex-e-x)/2 ,其中用一个函数求ex 。结果保留两位小数。

输入

x

输出

sinh(x)的值。

样例输入

copy

1

样例输出

1.18

提示

 主函数已给定如下,提交时不需要包含下述主函数

/* C代码 */

int main(){

 double x;

 scanf("%lf",&x);

 printf("%.2f\n",udf_sinh(x));

 return 0;

}

/* C++代码 */

int main(){

 double x;

 cin>>x;

 cout<<setiosflags(ios::fixed);

 cout<<setprecision(2);

 cout<<udf_sinh(x)<<endl;

 return 0;

}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<set>
#include<stack>
#define e 2.71828182
using namespace std;
double udf_sinh(double x)
{
    double s1,s2;
    s1=pow(e,x);
    s2=pow(e,-x);
    return (s1-s2)/2;
}

猜你喜欢

转载自blog.csdn.net/weixin_44170305/article/details/90209959
今日推荐