程序有幾個問題:
1.long double型數(shù)據(jù)輸入輸出都要用%lf,而你都用的是%f.
2.if(i=1)此處應(yīng)該為(x==1)
3.while(pow(x,j)/p1e-5
目前就發(fā)現(xiàn)這么多錯誤,但是答案貌似不對.你再檢查檢查.
用C語言程序算sinX的值
用C語言程序算sinX的值
題目:利用泰勒級數(shù)sinx≈x-x^3/3!+x^5/5!-x^7/7!+x^9/9!-…,計(jì)算sinx的值.要求最后一項(xiàng)的絕對值小于10^-5,并統(tǒng)計(jì)出此時累加了多少項(xiàng).
#include
#include
void main()
{
long double x,sinx;
int i=0,j=1;
long p=1;
printf("In sinx,x=");
scanf("%f",&x);
do{
i++;
if(i=1)
sinx=(pow(x,j))/p;
else if(i%2==0)
sinx=sinx-(pow(x,j))/p;
else
sinx=sinx+(pow(x,j))/p;
p=p*(j+1)*(j+2);
j=j+2;
}while(pow(x,j)/p
題目:利用泰勒級數(shù)sinx≈x-x^3/3!+x^5/5!-x^7/7!+x^9/9!-…,計(jì)算sinx的值.要求最后一項(xiàng)的絕對值小于10^-5,并統(tǒng)計(jì)出此時累加了多少項(xiàng).
#include
#include
void main()
{
long double x,sinx;
int i=0,j=1;
long p=1;
printf("In sinx,x=");
scanf("%f",&x);
do{
i++;
if(i=1)
sinx=(pow(x,j))/p;
else if(i%2==0)
sinx=sinx-(pow(x,j))/p;
else
sinx=sinx+(pow(x,j))/p;
p=p*(j+1)*(j+2);
j=j+2;
}while(pow(x,j)/p
其他人氣:284 ℃時間:2020-06-04 23:04:42
優(yōu)質(zhì)解答
我來回答
類似推薦
- 求sinx的近似值
- You will ask for what you A will do B have done C had done D do 選B 為什么
- 計(jì)算:x-1的絕對值
- The two pictures look the same to me.It's hard to ( )one from the other.
- Recently,great changes have taken place in my home town.這句話成立嗎?
- 已知關(guān)于X的方程A(5X-3)=6X+10無解,試求A
- 三角形ABC中D在邊AB上角ACD等于角ABC,AC等于3,AD等于1則DB等于幾
- 我國最大的鹽場是_;我國最大的漁場是_.
- 作者從養(yǎng)花中體會到的樂趣有哪些?結(jié)合課文的事例
- 把win添加一個字母變成一個新單詞,pian,than,here,read和see呢?
- 0.03化成小數(shù)
- The nazi kept those___in their concentration camp
猜你喜歡
- 1生化反應(yīng)池的工作原理是什么?
- 2(Ⅰ)解關(guān)于x的不等式:x2-2x+1-a2≥0; (Ⅱ)已知集合A是函數(shù)y=lg(20+8x-x2)的定義域,p:x∈A,q:x2-2x+1-a2≥0(a>0),若?p是q的充分不必要條件,求a的取值范圍.
- 3在第29屆奧運(yùn)會上,中國的運(yùn)動健兒共取得幾枚金牌?
- 4若m、n互為相反數(shù),則(3m-2m)-(2m-3n)的值為__________________
- 5在除法里,114除以6等于幾|?
- 6人教版六年級語文上冊第二單元作文的讀后感急急急!
- 7下列物質(zhì)溶于水時放出熱量使溶液溫度升高的是
- 8有機(jī)化學(xué)中的官能團(tuán)有哪些?
- 9哪錯了?select score1.學(xué)號,score1.課程號,course.成績 from score1,course where score1.課程號=course
- 10水遇到電時會產(chǎn)生什么反應(yīng)
- 11350*48-35*80分配律怎么算
- 12英語翻譯