1017

没完全成功~

#include
#include
#include
#include
#include
#include

using namespace std;


int main()
{
    array a = {0};
    string tmp;
    unsigned b;
    cin >> tmp;
    cin >> b;

    unsigned n = 0;
    for (auto r : tmp)
    {
        string r_s(1, r);
        a[n] = stoi(r_s);
        ++n;
    }

    array q = {0};
    unsigned r=0;
    unsigned tmp_q = 0;
    unsigned tmp_r=0;
    unsigned tmp_sum=a[0];
    for (unsigned i = 0; i < n; ++i)
    {
        tmp_q = tmp_sum / b;
        tmp_r = tmp_sum%b;
        tmp_sum = tmp_r * 10 + a[i + 1];
        q[i] = tmp_q;
    }
    r = tmp_r;

    if (q[0] == 0)
    {
        for (unsigned i = 1; i < n; ++i)
        {
            cout << q[i];
        }
    }
    else
    {
        for (unsigned i = 0; i < n; ++i)
        {
            cout << q[i];
        }
    }
    cout << " " << r;

    system("pause");
    return 0;
}

你可能感兴趣的:(1017)