小编Sup*_*man的帖子

我试图用C++ for循环计算一定数量,但我一直得到"程序已停止工作"错误消息

我试图在Dev C++中运行此代码:

    #include<conio.h>
    #include<iostream>


    using namespace std;

    int main()
    {
        float sum =1;
        int num = -1;

        for(int i=1; i<=1000; i++)
        {
            num *= i;
            sum += 1/(num);
        }
        cout<<sum<<endl;
        getch();
        return 0;
    }
Run Code Online (Sandbox Code Playgroud)

每当我编译并运行代码时,我都会收到程序已停止工作的Windows错误消息.有人可以帮帮我吗?

使用此代码,我试图计算以下总和:

Σ1/ n!

n = 0的

c++ math eulers-number

-1
推荐指数
1
解决办法
94
查看次数

标签 统计

c++ ×1

eulers-number ×1

math ×1