全能萬進製高精度模板

2021-09-30 11:58:00 字數 1429 閱讀 4128

#include

#include

#include

#include

#include

#include

using namespace std ;

typedef long long llong ;

const int size = 50000 ;

const int base = 10000 ; //高精度數字中每乙個元素表示數字的幾位,100就是2位。1000就是4位。

const int cap = 50000 ;

struct bignum

bignum( int x ):len(0)

bignum( const bignum &x ):len(x.len)

int &operator( int posi )

int operator( int posi )const

};int cmp( const bignum &a, const bignum &b ) //比較 兩個高精度數的大小 1是a大,-1是b大 0是相等。

bignum operator+( const bignum &a, const bignum &b )

r.len = i ; return r ;

}bignum operator-( const bignum &a, const bignum &b )

//高精度乘單精度,單精度必須放在右邊

bignum operator*( const bignum &a, const int &b )

r.len = a.len ; while( r.len>0&&0==r[r.len-1] ) r.len-- ;//消除字首0

return r ;

}llong mod( const bignum &a, const int &b )

carry = carry + a[i] ; carry = carry % b ;

return carry ;

}istream &operator>>( istream &in, bignum &x )

return in ;

}ostream &operator<<( ostream &out, const bignum &x )

void mytostr( string &str, const bignum &x )

for( int i=x.len-2; i>=0; i-- )

for( int j=base/10; j>0; j/=10 )

str += char(x[i]/j%10+'0') ;

str.reserve() ;

}int main()

{bignum a,b,c;

cin>>a;

cin>>b;

c=a*b;

cout<

萬進製高精度乘法

program hpm type arr array 1.1000 of longint var a,b,c arr lena,lenb,len1,len2,t1,t2 longint procedure init var s,temp ansistring i longint begin read...

高精度進製轉換模板

高精度進製轉換模板 高精度進製轉換 把oldbase 進製的數轉化為newbase 進製的數輸出。呼叫方法,輸入str,oldbase newbase.change solve output 也可以修改output 使符合要求,或者存入另外乙個字元陣列,備用 include include defi...

高精度模板

include include include includeusing namespace std define maxn 9999 define maxsize 10 define dlen 4 class bignum bignum const int 將乙個int型別的變數轉化為大數 big...