已关闭问题

在线诊断 自然底数C++程序输出为什么为NaN

5
[ 标签:c++ 输出,底数,nan ]

#include <iostream.h>
using namespace std;
int main()
{
float e=1,j=1;
int i=0;
do
{i=i+1;
j=j*i;
e=e+1/j;
}
while(j<100000);
cout<<e<<endl;
}
上面是我的程序。。。

有错误的话帮帮忙指出来

い゛离别╭ 回答:1 人气:7 提问时间:2009-11-05 20:32

答案

#include <iostream.h>
using namespace std;

错了.改成:

#include <iostream>
using namespace std;

程序没有错误. 运行结果是2.71828.

截图如下:


相关内容