1136 A Delayed Palindrome(20 分)

#include 
#include 
#include 
#include 
#include 
#include
using namespace std;

int M, N, L, K, a, b, c;
string suma;
bool huiwen(string input1, string input2)
{
    if (input1 == input2)
        return true;
    else
        return false;
}

string  add_str(string str_a, string str_b)
{
    reverse(str_a.begin(), str_a.end());
    reverse(str_b.begin(), str_b.end());
    if (str_b.size()9)
        {
            flag_1 = true;
            a -= 10;
        }
        out_str += to_string(a);
    }
    if (flag_1==true)
    {
        out_str += '1';
    }
    reverse(out_str.begin(), out_str.end());
    return out_str;
}

int main()
{
    cin >> suma;
    int cnt = 0;
    for (; cnt < 10; cnt++)
    {
        string str1(suma);
        string s(str1.rbegin(), str1.rend());
        if (huiwen(str1, s))
        {
            cout << suma << " is a palindromic number." << endl;
            break;
        }
        suma=add_str(suma, s);
        cout << str1 << " + " << s << " = " << suma << endl;
    }
    if (cnt == 10)
    {
        cout << "Not found in 10 iterations." << endl;
    }
    system("pause");
    return 0;
}

你可能感兴趣的:(1136 A Delayed Palindrome(20 分))