Home > Back-end >  Is there any wrong bosses to give directions
Is there any wrong bosses to give directions

Time:06-11




Input x, calculation formula of the top 10 and above,

#include
#include
#include

Int main ()
{double x, I, sum, flag, a, b, j.
flag=1;
sum=0;
B=1;

Lf the scanf (" % ", & amp; X);
A=1/x;
for(i=1; i<=10; I++)
{a=a * x * x;

for(j=1; j<=2 * I - 1; J++)
B=b * j;


The sum +=flag * a/b;
Flag=- flag;

}
Printf (" % 3 "f, sum);
return 0;
}

CodePudding user response:

B take too much, or every time before calculating the assignment 1 b, or the cycle change j

CodePudding user response:

In the first layer circulation first sentence plus b=1; Or b will keep the previous value

CodePudding user response:

refer to the second floor datoulaile123 response:
cycle in the first sentence in the first layer and b=1; Or b will keep the previous value

Why keep ah, should not be LianCheng

CodePudding user response:

reference wfdhua reply: 3/f
Quote: refer to the second floor datoulaile123 response:
cycle in the first sentence in the first layer and b=1; Or b will keep the previous value

Why keep ah, should not be a LianCheng

You see your a, and your b, compare the difference between your a reserved * two x again and realize the index function, you b retain is boring, after all, you each time from 1 began to calculate the factorial

CodePudding user response:

Understand, thank you, the problem has been solved

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related