高精度除法(高精除底精)

代码:

#include
#include
using namespace std;
const int N = 1110;
using namespace std;
int main()
{
    string s;//被除数的字符形式
    int x;//除数
    cin>>s>>x;
    int a[N] = {0};//记录被除数的整数形式
    int ans[N] = {0}; //记录商
    int re = 0;//记录余数
    int len = s.length();
    if(x == 0){ //如果除数为零, 是不正确的 
        cout<<"除数不能为0"<= 0;i--)
    {
        re = re * 10 + a[i];//竖式除法
        ans[i] = re/x;
        re %= x;
    }
    while(ans[len] == 0 && len > 0)len--; //除去前导零
    for(int i = len;i >= 0;i--) cout<

。。。(高精除高精待续...)

你可能感兴趣的:(算法,c++,数据结构)