1017

作者: 峡迩 | 来源:发表于2017-07-21 23:30 被阅读0次

    没完全成功~

    #include<iostream>
    #include<array>
    #include<cctype>
    #include<string>
    #include<vector>
    #include<algorithm>
    
    using namespace std;
    
    
    int main()
    {
        array<int, 1001> 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<int, 1001> 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

          本文链接:https://www.haomeiwen.com/subject/cgsykxtx.html