我的代碼不表示精確的浮點值指數後不被 我使用的Turbo C爲總結該系列中的代碼顯示點1 + 1/3 1/5 + + 1/7 + 1/9 + ... ..多達N項我的C++代碼不表示浮點值
#include<iostream.h>
#include<conio.h>
void main()
{
int k=0;
int m=0;
int s=1;
clrscr();
cout<<"Enter the limit of the series: ";
cin>>m;
for(int j=1;j<=m;j=j+2)
{
m=1/j;
s+=m;
}
cout<<"Sum of the given series is: "<<s;
getch();
}
'int'在**整數**中。改用'double'。 – Angew
重複數百次。 –
任何時候,你問你給什麼輸入你的程序的問題,您應該清楚闡明(** ** 1),(** 2 **)你所期望的輸出,並且(** 3 **)輸出什麼,你居然得到。這三個問題都失敗了。 – abelenky