窗口弹出:X.exe已停止工作(code ::块) [英] Windows popup: X.exe has stopped working (Code::Blocks)

查看:1255
本文介绍了窗口弹出:X.exe已停止工作(code ::块)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此先感谢在此考虑看看。

我收到的时候我尝试运行这个程序我用C在code :: Blocks的写了一个Windows错误信息。有趣的是,它编译罚款,如果我降低上限的什么,我测试程序运行罚款以及。

详细内容:

当我尝试运行该程序,首先我得到一个Windows弹出,上面写着X.exe已停止工作。Windows正在检查一个解决问题的办法。不久,这种改变为X.exe已停止工作。一个问题导致程序停止正常工作。Windows将关闭该程序并通知您如果解决方案是可用的。(关闭程序)我点击关闭程序按钮,然后我看到命令提示符,上面写着进程返回255 LT; 0xFF的>执行时间3.940小号preSS任意键继续。

我的Windows 8。

我使用的GNU GCC编译器。

如果我改变高达到100000,该程序工作正常。

这里的code:

  / ********* ***********
*查找百万之下起始整数
*产生最长在Collat​​z序列,并且
*所述序列的长度。
******************* /#包括LT&;&stdio.h中GT;
#包括LT&;&stdlib.h中GT;
#包括LT&;&math.h中GT;
#包括LT&;&ASSERT.H GT;
#包括LT&;&limits.h中GT;
#定义高达百万诠释的main()
{
    我长;
    久龙J;
    长长最大= LONG_LONG_MAX;
    长的长度= 0;
    长数= 0;
    长penull = 0;
    长LEN [高达]
    对于(I = 0; I&下;高达;我+ +)(LEN [I] = 0);
    //计算在Collat​​z序列长度启动整数从1到999999
    对于(i = 1; I<高达,我++)
    {
        J =;
        而(J!= 1)
        {
            断言(J&下; =(最大 - 1)/ 3);
            如果(J%2 == 0)(当J = J / 2);
            否则(J = 3 * J + 1);
            LEN [I] ++;
            如果(J< I)
            {
                LEN [I] = LEN [I] + LEN [J]。
                J = 1;
            }
        }
        //存储最长序列的长度和起始整数生产它
        如果(LEN [Ⅰ]≥长度)
            {
                长度= len个[I]
                数= I;
            }
        //保存供以后比较的重复长度
        否则,如果(LEN [I] ==长度)(penull = len个[I]);
    }
    如果(长度== penull)(输出(至少有二!));
    其他的printf(%LD生产长度%LD的在Collat​​z序列,数量,长度+ 1);
    返回0;
}


解决方案

移动阵列 LEN 之外功能。栈的大小有时限定,局部变量存储在栈上。由外部移动它,你让一个全局变量。

thanks in advance for taking a look at this.

I'm getting a Windows error message when I try to run this program I wrote in C in Code::Blocks. The funny thing is it compiles fine, and if I lower the upper bound of what I'm testing the program runs fine as well.

Details:

When I try to run the program, first I get a Windows popup that says "X.exe has stopped working. Windows is checking for a solution to the problem". Shortly this changes to "X.exe has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. (Close program)" I click the close program button, and then I see the command prompt that says "Process returned 255 <0xFF> execution time 3.940 s Press any key to continue".

I have Windows 8.

I'm using the GNU GCC compiler.

If I change "upto" to 100000, the program works fine.

Here's the code:

/************************************************
* Finds the starting integer under 1000000 that
* produces the longest Collatz sequence, and the
* length of said sequence.
*************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <limits.h>
#define upto 1000000

int main()
{
    long i;
    long long j;
    long long max = LONG_LONG_MAX;
    long length = 0;
    long number = 0;
    long penull = 0;
    long len[upto];
    for (i = 0; i < upto; i++) (len[i] = 0);
    // counts length of Collatz sequence for starting integers from 1 to 999999
    for (i = 1; i < upto; i++)
    {
        j = i;
        while (j != 1)
        {
            assert (j <= (max - 1)/3);
            if (j%2 == 0) (j = j/2);
            else (j = 3*j + 1);
            len[i]++;
            if (j < i)
            {
                len[i] = len[i] + len[j];
                j = 1;
            }
        }
        // stores length of the longest sequence and the starting integer producing it
        if (len[i] > length)
            {
                length = len[i];
                number = i;
            }
        // stores a duplicate length for later comparison
        else if (len[i] == length) (penull = len[i]);
    }
    if (length == penull) (printf("There are at least two!"));
    else printf("%ld produces a Collatz sequence of length %ld", number, length + 1);
    return 0;
}

解决方案

Move the array len outside the main function. The size of the stack is sometimes limited, and local variables are stored on the stack. By moving it outside, you make it a global variable.

这篇关于窗口弹出:X.exe已停止工作(code ::块)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆