沒完全成功~
#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;
}