大整數除法(進製轉換)

2021-08-22 06:07:09 字數 534 閱讀 4428

將乙個長度最多為30位數字的十進位製非負整數轉換為二進位制數輸出。

多組資料,每行為乙個長度不超過30位的十進位製非負整數。

(注意是10進製數字的個數可能有30個,而非30bits的整數)

每行輸出對應的二進位制數。

985

2111126

1111011001

11010011

10001100110

這道題要注意長度為30為的十進位制整數已經超過了long long表示的範圍,這個時候應該採用字元陣列記錄下輸入的整數,然後通過人工模擬整數除法的方式,採用短除法記錄下每個步驟產生的商和餘數,最後再將商和餘數輸出。

#include #include #include char str[50];

int bits[100];//用了記錄每次的餘數

int num[30];//用了記錄每次的商

int main()

}printf("\n");

}return 0;

}

大整數除法

define maxint 1000 define max 200 int num1 max 10 int num2 max 10 unsigned int total max 10 int sub int a,int b int i 0 for a b i return i cstring big...

大整數任意進製轉換

include include include include using namespace std char str 1000 輸入字串 int start 1000 ans 1000 res 1000 被除數,商,餘數 轉換前後的進製 static int oldbase static int...

高精度正整數除法 大整數除法

標籤 空格分隔 演算法競賽 演算法 程式設計錯題 高精度 單詞 divident 被除數 divisor 除數 quotient 商大整數除法 openj bailian 2737 題目要求 求兩個大的正整數相除的商。input 第1行是被除數,第2行是除數。每個數均不超過100位。output 一...