【问题标题】:Runtime Error - SIGABRT unable to find the bug help me with it运行时错误 - SIGABRT 无法找到错误帮助我解决它
【发布时间】:2016-12-05 02:05:06
【问题描述】:

问题是关于一个给定的数字 N,其位数在 1 到 10^5 之间。如果提供 2 个数字 s 和 f 小于 N 并且 s

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string N; cin>>N;
    long long T; cin>>T;
    string sub="";
    long long i,s,f,val;
    while(T--){
        cin>>s>>f;
        s--; f--;
        sub = "";
        for(i=s;i<=f;i++)
                sub+=N[i];
        val = stoi(sub);
        if(val%7==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

【问题讨论】:

    标签: c++ runtime-error sigabrt


    【解决方案1】:

    “sigabrt 但我的代码都是正确的” - 显然不是。

    调试的第一条规则:写的代码有bug,你的工作就是找到它。

    您的代码显然会根据输入而崩溃。我会考虑调试代码而不是声称它必须是正确的。

    【讨论】:

    • 谢谢。让我再提出几个提到的条件。 1
    猜你喜欢
    • 2021-12-11
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    相关资源
    最近更新 更多