高精度進製轉換模板

2021-06-29 16:56:21 字數 822 閱讀 2109

高精度進製轉換模板

/*

高精度進製轉換

把oldbase 進製的數轉化為newbase 進製的數輸出。

呼叫方法,輸入str, oldbase newbase.

change();

solve();

output();

也可以修改output(),使符合要求,或者存入另外乙個字元陣列,備用

*/#include#include#defien maxsize 1000

char str[maxsize];//輸入字串

int start[maxsize],ans[maxsize],res[maxsize];//被除數,商,餘數

int olebasw,newbase;//轉換前後的進製

//單個字元得到數字

int getnum(char c)//這裡進製字元是先數字,後大寫字母,後小寫字母的

//數字得到字元

char getchar(int i)

void change()//把輸入的字串的各個數字還原為數字形式

void solve()

res[++res[0]]=y;//這一輪得到的餘數

i=1;//找下一輪商的起始處,去掉前面的0

while(i<=ans[0]&&ans[i]==0) i++;

memset(start,0,sizeof(start));

for(j=i;j=1;i--)

printf("%d",getchar(res[i]));

printf("\n");

}

進製轉換 高精度除法 進製轉換

高精度除法運算 include include include using namespace std struct bign bign change char str return a bign divide bign a,int b,int r 去除前導0 while c.len 1 1 c.d...

poj1220 高精度進製轉換模板

include include includeusing namespace std const int maxs 1000 int oldbase,newbase 原進製,新進製 char origin maxs 原串 int str maxs ans maxs goal maxs 被除數,除數,...

任意進製轉換(高精度)

2019銀川現場 62進製以內的任意進製轉換 板子 includeusing namespace std const int n 1000 char s1 n s2 n int a n t n n,m n進製轉m void solve a k t 0 m t 0 m 單獨處理最後一位 while l...