Home > Back-end >  No comments SCN function is what the result is not correct, please great god answers, really can not
No comments SCN function is what the result is not correct, please great god answers, really can not

Time:09-30

#include
#include
Int JC (int y);
Double SCN (double x);
using namespace std;
Const double TINY_VALUE=https://bbs.csdn.net/topics/1e-10;


The main ()
{
Double r, s,
Double k;
Cout<" Please enter the r or s & lt;" cin> r;
cin> s;


If (r * r<=s * s)
{
K=SQRT (SCN (r) * SCN (r) + SCN (s) * the SCN (s));
}
The else
{
K=(1/2.0) * SCN (r * s);
}
Cout<" The result is equal to="& lt;
return 0;
}
/* double SCN (double x)
{
Double g=0;
Double t=x;
Int n=1;

Do {
G +=t;
n++;
T=t * x * x/(2 * n - 1)/(2 * n - 2);
} while (fabs (t) & gt;=TINY_VALUE);

Return g;
} */

Int JC (int y)
{
int n;
N=y;
If (n!
=1)JC n=n * (n - 1);
The else
return 1;
Return n.
}

Double SCN (double x)
{
A double v=0;//the return value
Int FM=1;//the denominator
Int o=1;
Int g;
Double e=x;
Do
{
G=e/o;
If (FM % 4==1)
V=v + g;
The else
{
V=v - g;
}
E=e * * x (x);
FM=(FM + 2);
O=JC (FM);
} while (fabs (g) & gt;=TINY_VALUE);
Return v.
}



  • Related