高精度運算 465 Overflow

2021-07-15 20:06:38 字數 682 閱讀 4516

題目大意:給出兩個非負整數和運算子,判斷非負整數和運算結果是否越界,c中以int為界,最大值2147483647

解題過程:runtime error 2次,wa無數次。。在判斷加法時沒什麼陷阱,在判斷乘法時,要考慮到乙個因數為0時,即使另乙個因數越界,結果也不會越界,還有乙個考慮不周的地方就是要去掉前導0,坑爹。。。

正確**:

# include # include # include # include # include # include # include # include //*

#define fin cin

#define fout cout

//*/

# define maxn 10

using namespace std;

/*ifstream fin("in.txt");

ofstream fout("out.txt");

//*/

struct bign

bign operator = (const char * num)

else

else

} if(s2.length()>maxn)

else

else

} if(op=='+')

else

if(!isa&&!isb&&!isres) fout<

高精度運算

今天覆習了一下高精度運算。我覺得這種簡單的東西也得看一看,至少給自己留點兒低!高精度可以壓位的,但我今年懶得寫了 首先是加減法很簡單了,沒什麼值得特別強調的。高精度減法時別忘了,a時做下交換在計算,輸出時別忘了標記負號。高精度乘法需要注意的問題是,要在做完乘法之後再調整為十進位制。有的初學者小盆友喜...

高精度運算

雖說高精度直接考查的越來越少,不過還是以防萬一。define maxlen 1000 struct bint 本模板既可輸入字串,也可輸入整數 bint int t if len 1 len bint char str print number friend void print bint bi p...

高精度運算

name 高精度運算 author goal00001111 date 01 12 08 15 04 description 高精度運算 加減乘除,乘方,階乘 include include using namespace std void reverse string str void addin...