中止的中止信号(3)(SIGABRT)

时间:2019-03-15 13:03:12

标签: c++ signals sigabrt abort

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(int sum)
{
    string s1 = to_string(sum);
    string s2 = s1;
    reverse(s2.begin(), s2.end());
    for (long long int i = 0; i < sizeof(s2); i++)
    {
        if (s1[i] != s2[i])
            return false;
    }
    return true;
}

int main()
{
    long long int num, sum, count = 0;
    cin >> num;
    sum = num;
    string s1, s2;

    while (count <= 1000 && sum <= 4294967295)
    {
        s1 = to_string(sum);
        s2 = s1;
        reverse(s2.begin(), s2.end());
        int temp = stoi(s2, 0, 10);
        sum += temp;
        count++;

        if (isPalindrome(sum))
        {
            cout << count << " " << sum << endl;
            return 0;
        }
    }

    cout << "Not Possible" << endl;

    return 0;
}

我为什么得到Abort signal from abort(3) (SIGABRT)? 我不知道SIGABRT是什么。有人可以解释一下吗?访问内存中是否缺少任何内容?还是那些内置函数有错误?

0 个答案:

没有答案