如:1234 / 7
商:0176 余2
去掉前面的0 但是也要至少保留1位 跟减法类似
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
string a,res;
int b;
cin>>a>>b;
int r = 0; //余数
for(int i = 0; i < a.size(); i++){
int u = a[i] - '0';
r = r * 10 + u;
if(r < b) res += '0';
else{
res += to_string(r / b);
r = r % b;
}
}
int k = 0;
while(k != res.size() - 1 && res[k] == '0') k++;
res = res.substr(k);
cout<<res<<endl;
cout<<r<<endl;
return 0;
}