再学完这个知识点,我再休息算法思想代码实现1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include <iostream>#include <cstring>#include <algorithm>using namespace std;vector<int> div(vector<int> A, int b, int & r){ // 默认A大于b vector<int> C; r = 0; // 除法是从最高位开始 <- for(int i = A.size() - 1; i >= 0; i--){ r = r * 10 + A[i]; C.push_back(r / b); r %= b; } // 保存的时候是从高到低,需要反转一下 reverse(C.begin(), C.end()); // 去除前导0 while(C.size() > 1 && C.back() == 0) C.pop_back(); return C;}int main(){ string a; int b; cin >> a >> b; vector<int> A; for(int i = a.size() - 1; i >= 0; i--) A.push_back(a[i] - '0'); int r; // 余数 vector<int> C = div(A, b, r); for(int i = C.size() - 1; i >= 0; i--) cout << C[i]; cout << endl << r; return 0;}