本题不用思考太复杂,思想就是把输入的数拆成一个个数和d相除,不断输出结果把余数放到最后在输出。
#include<stdio.h>
#include <stdlib.h>
#include <iostream>
#include<string>
#include<math.h>
using namespace std;
int main() {
string s;
int b;
cin >> s >> b;
int t=0;
int yushu=0;
t = (s[0] - 48) / b;
if (t != 0 || s.length() == 1) {
cout << t;
}
yushu = (s[0] - 48) % b;
for (int i = 1;i < s.length();i++) {
t = (yushu*10 + (s[i] - 48)) / b;
cout << t;
yushu= (yushu*10 + (s[i] - 48)) % b;
}
cout << " " << yushu;
}