繁体   English   中英

我在输出中得到thread1:SIGNAL sigbart

[英]I am getting thread1:SIGNAL sigbart in output

这是我的代码,请帮帮我! 我正在使用xcode ..我想生成一个多项式序列,然后对各项进行异或运算并反馈到第一个输入位,因为它是8位,它完成了2 ^ 8-1次。有用的,谢谢

#include "32bit.h"
#include<iostream>

using namespace std;
int main()
{
    bool input[8];
    int n;
    bool out=0;
    cout<<"Enter the no of terms ";
    cin>>n;
    int temp1[n];
    int gen=0;
    bool store[255];
    cout<<"Input power of x in increasing order, Omit x^0";


    for(int i=0;i<n;i++)
        cin>>temp1[i];
    cout<<"Enter key to generate ";
    cin>>gen;
    for(int m=0;m<255;m++)
    {
        store[m]=input[gen];
        bool temp2[n];
        int var=0;
        for(int j=0;j<n;j++)
        {

            var=temp1[j];
            temp2[j]=input[var];
        }
        int c=0;
        for(int k=0;k<n;k++)
        {
            if(temp2[k]%2==1)
                c++;

        }
        if(c%2==1)
            out=1;
        else
            out=0;
        for(int l=0;l<8;l++)
            input[l+1]=input[l];
        input[0]=out;
    }
    for(int p=0;p<255;p++)
        cout<<store[p];
}

这里有一个超出范围的数组访问:

    for(int l=0;l<8;l++)
        input[l+1]=input[l];

因为input的大小仅为8,并且您试图在此循环的最后一次迭代中写入input[8] (即不存在的第9个元素)。 我猜可能应该是:

    for(int l=0;l<7;l++)
        input[l+1]=input[l];

暂无
暂无

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

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