高精度除法(高精度除以高精度)

2021-06-17 16:36:36 字數 759 閱讀 7026

先貼乙個簡單的高精度除以單精度的:

#include #include #include using namespace std;

int main()

else ys=ys*10+a[i]-'0';

} while (c[i]==0) i--;

for (int j=i;j>=0;j--)

printf("%d",c[j]);

if (ys) printf(" %d",ys);

printf("\n");

} return 0;

}

然後就是高精度除以高精度了,原理利用高精度減法求商吧...很蛋疼的是各種資料ok,就是ac不了,不知道為什麼,哪位指出錯誤,感謝...

#include #include #include #include using namespace std;

char c[510];

int ff(char a[510],char b[510])

t++;

} while (cc[t]==0) t--;

int ff=t;

memset(c,0,sizeof(c));

for (int j=t;j>=0;j--)

c[ff-j]=cc[j]+'0';

c[ff+1]='\0';

return ff+1;

}int main()

}f[t++]='\0';

cout<

高精度除以高精度

原 題 高精除以高精,求它們的商和餘數。演算法分析 高精除以高精是用減法模擬除法,對被除數的每一位都減去除數,一直減到當前位置的數字 包括前面的餘數 小於除數 由於每一位的數字小於10,所以對於每一位最多進行10次計算 代 碼 include include include using namesp...

9111 高精度除法 高精度除高精度

time limit 1 second memory limit 2 mb 問題描述 輸入兩個高精度非0整數,輸出它們的整數商 不考慮小數部分 輸入只有兩行,第一行乙個整數x,第二行乙個整數y。其中0 x 10 200,0 y 10 200 輸出有1行,為兩個數的整數商。22222222223333...

9111 高精度除法 高精度除高精度

time limit 1 second memory limit 2 mb 問題描述 輸入兩個高精度非0整數,輸出它們的整數商 不考慮小數部分 輸入只有兩行,第一行乙個整數x,第二行乙個整數y。其中0 x 10 200,0 y 10 200 輸出有1行,為兩個數的整數商。22222222223333...