简体   繁体   English

该程序在执行时停止工作。 我用代码块制作了这个程序

[英]This program stops working while execution . i made this program in codeblocks

Why does this program stops working with a message which says process returned -1073741819 on codeblocks ? 为什么该程序停止处理一条消息,该消息指出进程在代码块上返回了-1073741819? All other programs are working on code blocks except for this one. 除此程序外,所有其他程序都在代码块上工作。 This is my uncompleted project for my college assingment. 这是我尚未完成的大学评估项目。

    #include<iostream>
    #include<vector>
    #include<math.h>
    #include<cstdlib>
    using namespace std;
    int main()
    {
        cout<<"\tThis is a C++ program to implement Quine-McCluskey logic to minimize a given Boolean function"<<endl;
        unsigned int nv,nmin,roll,i;
        vector<int> minterms;
        cout<<"Enter your roll number    ";
        cin>>roll;
        srand(roll);
        cout<<endl<<"Enter the number of variables(1-10)";
        cin>>nv;
        if(nv<1||nv>10)
        {
            cout<<endl<<"Invalid number of variables";
            exit(0);
        }
        cout<<endl<<"Enter the number of min-terms(1-"<<pow(2,nv)<<")   ";
        cin>>nmin;
        if(nmin<1||nmin>pow(2,nv))
        {
            cout<<"Invalid number of min-terms(1-"<<pow(2,nv)<<")";
            exit(0);
        }/*it stops here*/
        for(i=0;i<nmin;i++)
        {
            minterms[i]=rand()%int(pow(2,nv));
        }
        cout<<endl<<"The randomly generated min-terms are ";
        for(i=0;i<nmin;i++)
        {
            cout<<minterms[i]<<"  ";
        }

    }

You're not allocating any space in the minterms vector. 您没有在minterms向量中分配任何空间。 Instead of assigning to minterms[i] , pass the values to minterms.push_back() . 而不是分配给minterms[i] ,而是将值传递给minterms.push_back()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM