1048

// PATn.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include
#include



using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size())
    {
        b = string(a.size() - b.size(), '0') + b;
    }
    else
    {
        a = string(b.size() - a.size(), '0') + a;
    }

    size_t count = a.size();
    string out_number;
    for (int i = count - 1,j=1; i >= 0; --i,++j)
    {
        if (j % 2 == 1)
        {
            int tmp = ((a[i]-'0') + (b[i]-'0')) % 13;
            if (tmp == 10)
                out_number = "J" + out_number;
            if (tmp == 11)
                out_number = "Q" + out_number;
            if (tmp == 12)
                out_number = "K" + out_number;
            if (tmp < 10)
                out_number = to_string(tmp) + out_number;
        }
        else
        {
            int tmp = b[i] - a[i];
            if (tmp < 0)
                tmp = tmp + 10;
            out_number = to_string(tmp) + out_number;
        }
    }

    cout << out_number;

    system("pause");
    return 0;
}

你可能感兴趣的:(1048)