写了一个异或的函数

//TruncatedStepRow
template<size_t WIDTH> template<size_t W>
TruncatedStepRow<WIDTH>::TruncatedStepRow(const TruncatedStepRow<W>&amp; a, const TruncatedStepRow<W>&amp; b, size_t len, size_t lenIndices, int lenTrim) :
        StepRow<WIDTH> {a}
{
    cout<<&quot;len=&quot;<<len<<endl;                            //30
    cout<<&quot;lenIndices=&quot;<<lenIndices<<endl;              //1
 //   cout<<&quot;lenTrim=&quot;<<lenTrim<<endl;                    //3
    assert(len+lenIndices <= W);
    assert(len-lenTrim+(2*lenIndices) <= WIDTH);

//    unsigned char  hash[len-lenTrim];
    
    cout<<&quot;colision hash a =&quot;;
    for(long long unsigned int i=0;i<len;i++){
        cout<<a.hash[i];
    }
    cout<<endl;
    cout<<&quot;colision hash b =&quot;;
    for(long long unsigned int i=0;i<len;i++){
        cout<<b.hash[i];
    }
    cout<<endl;

        for (int i = lenTrim; i < (int)len-lenTrim; i++){
        hash[i-lenTrim] = a.hash[i] ^ a.hash[i];
    }

 //    cout<<endl;
    print_hash(len-lenTrim);

    if (a.IndicesBefore(b, len, lenIndices)) {
        std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim);
        std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim+lenIndices);

    } else {
        std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim);
        std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim+lenIndices);

    }
    //cout<<endl;
    //cout<<endl;
}

相同的值异或应该是0才对,为什么输出还是4或者7 啊??
全部评论

相关推荐

头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
06-12 16:23
已编辑
小米_软件开发(准入职员工)
点赞 评论 收藏
分享
06-25 16:53
门头沟学院 Java
人力小鱼姐:简历可以直接用飞书模板 模拟面试可以试试ai,现在好多都还是免费阶段 像Sugar云面、多面鹅都不错,主要看面试后自己能不能复盘出有效信息
为了找工作你花了哪些钱?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务